Skip to content

feat: show encryption setup required state - #325

Merged
Yoshiofthewire merged 1 commit into
mainfrom
feat/encryption-setup-required
Nov 19, 2026
Merged

Yoshiofthewire merged 1 commit into
mainfrom
feat/encryption-setup-required

Conversation

@Yoshiofthewire

Copy link
Copy Markdown
Member

Part of #324 (part 1 only: encryption setup required. Conversations, send delay and masked identity are separate.)

What changed for the user

Since KyPost-Server #666, an account that still owes first sign-in encryption setup gets 403 {"error":"encryption_setup_required"} on every mailbox route. Until now the app treated that as a generic refusal and showed a toast on every 90 s poll. Now:

  • The inbox shows one full-pane state: Finish encryption setup, with the server's message as the body (or "Finish email encryption setup in KyPost on the web, then come back." if the server sends none), Open KyPost on the web (opens <serverUrl>/setup/encryption through the existing first-party openWebmail launcher) and Check again.
  • It is not a sign-out and not a network error. Pairing, keys, cached mail (Room), sync cursors and compose drafts are untouched. A send that hits it leaves Compose open with the server's message, the same as any refused send.
  • No retry loop. The 90 s inbox poll and the notification-message poll stop while the state is shown. The app checks again with one inbox request when it returns to the foreground or when you tap Check again. The first success clears the state and restarts the poll. Other failures (offline, 502) neither enter nor clear it.

How

  • MailOutcome.EncryptionSetupRequired(message?). It is decoded in one place, RelayMailSource's shared request paths (execute, executeStreaming, downloadAttachment), next to the 429 short-circuit, so no route's own status mapping can hide it. It matches on the JSON error code, never on prose.
  • EncryptionSetupGate holds the inbox state (enter on that 403, clear on success, ignore anything else). InboxActivity wires it into scheduleNextRefresh, the pending-message poll and a new inbox_encryption_setup layout included in both inbox layouts. Strings are in strings.xml.
  • refusedBeforeSending() counts it as refused (nothing was sent).

Tested (on Major, Gradle capped at 6 GB, --max-workers=2)

  • ./gradlew checkSigningSecretsAreNotInTheTree testPlayDebugUnitTest: BUILD SUCCESSFUL
  • ./gradlew testGithubDebugUnitTest testFdroidDebugUnitTest: BUILD SUCCESSFUL
  • ./gradlew lintPlayDebug lintGithubDebug lintFdroidDebug: BUILD SUCCESSFUL
  • ./gradlew assembleFdroidDebug assemblePlayDebugAndroidTest: BUILD SUCCESSFUL (proves the instrumentation APK compiles)
  • New tests:
    • RelayMailSourceTest: the 403 is recognised on the streamed, string and binary paths (inbox, send, body, scheduled, attachment). It is not Unauthorized and its wording never says re-pair. With no message, the app wording is used. Other 403s, prose-only bodies and the code on a 409 keep their old mapping.
    • EncryptionSetupGateTest: enter on 403; a repeat 403 is not a change, so the poll is not re-armed; other failures leave the state alone; success clears it.
    • MailRepositoryTest: a refresh that hits it leaves cached rows and the cursor untouched.
    • WebmailDeepLinkTest: the setup URL keeps the server's subpath and passes the first-party guard.
    • LayoutVariantIdsTest passes with the new ids in both layouts.

Not tested locally

  • Instrumentation and device tests: the Android emulator segfaults on Major, so GitHub CI runs these. I did not tap through the new screen on a device.
  • Against a live KyPost-Server with a held account: only the documented contract (docs/E2E_PGP.md "First sign-in setup") was used.

Security

  • No change to pairing, pinning or credential storage. The setup URL is built only from the pairing's serverUrl and goes through openWebmail's first-party check. No new dependency, network call or stored secret.
  • The server's message is shown as plain text in a TextView. Its length is bounded by the existing response-size limits.
  • Trade-off introduced: none.

AI involvement

  • Level: Agentic (Claude Code, Claude Opus 5.5). I ran a self-review of the diff. It found that a success landing after onStop could re-arm the poll in the background, which is fixed with a lifecycle guard. No unaddressed findings.

🤖 Generated with Claude Code

KyPost-Server #666 withholds every mailbox route with a 403
encryption_setup_required until the account finishes first sign-in
encryption setup. Treating it as a generic refusal toasted on every
90 s poll; the inbox now shows one setup screen, stops polling and
re-checks only on foreground return or Check again.

Part of #324

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire

Copy link
Copy Markdown
Member Author

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪

🧪 PR contains tests

🔒 No security concerns identified

⚡ No major issues detected


Advisory only: this comment never gates the pull request.
claude-sonnet-5-5 using pr-agent on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kypost-for-android-325, where it is readable by the operator and expires seven days after the last post.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


gpt-6.1-sol using security-audit on behalf of Yoshi

@Yoshiofthewire
Yoshiofthewire merged commit 00647e2 into main Nov 19, 2026
15 checks passed
@Yoshiofthewire
Yoshiofthewire deleted the feat/encryption-setup-required branch November 19, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant