feat(chat): scaffold StartChat with a required idempotency key - #1473
Merged
Merged
Conversation
flipcash2 sync e1f4116c makes idempotency_key a required field on StartChatRequest (upstream #102). Android had no StartChat call site to update, so this scaffolds the full chain instead: ChatApi.startChat builds and validates the request, ChatService maps the response Result enum to a new StartChatError sealed class, ChatRepository / InternalChatRepository add the domain-facing method, and ChatController exposes it. New IdempotencyKey and StartChatParameters domain types back the call. idempotencyKey is a required ChatController.startChat parameter with no default, so whichever caller originates a "create chat" action has to mint and reuse the same key across its own retries; nothing here generates one per call. Compiles: services:flipcash:compileDebugKotlin and compileDebugUnitTestKotlin against the local flipcash2-client-protocol override.
StartChat needs the idempotency_key field that 0.8.0 adds. Blocked until that version is on Maven Central.
bmc08gt
marked this pull request as ready for review
September 16, 2026 19:08
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft: blocked on code-payments/flipcash2-client-protocol#14. This branch pins
flipcash2-client-protocol0.8.0, which is not on Maven Central yet, so CI cannot resolve it — expectcom.flipcash:flipcash2-client-protocol:0.8.0 FAILED. It goes green once that PR merges and publishes.What changed upstream
StartChatRequestgained a requiredidempotency_key(field 9), backed by a new 16-byteIdempotencyKeymessage. Nothing was removed and nothing was renumbered.What this does
StartChathad never been scaffolded on Android — noChatApi,ChatService, repository or controller method existed for it. So this adds the RPC through the full existing Api → Service → Repository → Controller chain, mirroring howjoinChat/leaveChatare already wired, with the idempotency key required from the outermost entry point inward.IdempotencyKey— a 16-byte@JvmInline value classwith aSecureRandom-backedrandom(), matchingBlobId's shape.StartChatParameters— sealed interface with theGroupvariant the proto'sparametersoneof currently carries.StartChatError— the fiveResultcases plusUnrecognized/Other.ChatController.startChat(parameters, idempotencyKey)takes the key as a required parameter with no default and no internal generation. That is deliberate: the server derives the chat's identity from caller plus key, so a key minted inside the call, fresh per attempt, would satisfy validation while producing exactly the duplicate chats the field exists to prevent. Forcing the caller to supply it keeps minting where the user's intent originates.The signature covers the new field —
setIdempotencyKeyis chained beforeauthenticate(owner), which signsbuildPartial().Scope left open
There is no group-chat-creation UI on
code/cashto wire this into —NewChatScreen/NewChatViewModelonly handle DM-by-handle, andChatCoordinator.GroupOperationshas onlyjoin/leave.startChattherefore has no caller aboveChatController, so there is no retry path yet in which to reuse a key. The required parameter is what makes a future caller get it right rather than discover the constraint at runtime.No tests were added for
startChatitself.FakeChatRepositoryinChatControllerTestgained a stub override, since adding the method toChatRepositorybroke the only other implementer.Builds
Built against the client repo through
protoLocalRoot/protoLocalPackages=flipcash2, not a published artifact::services:flipcash:compileDebugKotlin— passes:services:flipcash:compileDebugUnitTestKotlin— passesNo wider
assembleDebugor:appbuild was run.