feat(chat): canonical DM chat-id derivation, DmChatResolver, concurrent feed sync - #1123
Merged
Conversation
Add ChatIdGenerator, which deterministically derives a DM's ChatId from
the two participants' user IDs: SHA-256 over a per-type domain
("flipcash:chat:dm" for CONTACT_DM, "flipcash:chat:dm:2" for TIP_DM) and
the unsigned-sorted, self-pair-collapsed member set. Mirrors the server's
MustDeriveDmChatID byte-for-byte so either side reaches the same id
without a prior lookup. Tests pin the wire-contract vectors (matching the
iOS TipDmChatIDTests).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Split DM-identity resolution out of MessagingOperations into a dedicated DmChatResolver interface (generateChatId / getChatId), implemented by a new DmChatResolverDelegate and composed into RealChatCoordinator via `by` delegation. MessagingOperations is left focused on operating on an existing ChatId. Add MessagingOperations.getOtherMember(chatId), returning the full ChatMember (profile incl. avatar) with a local-cache-then-network fallback; getOtherMemberE164 now delegates to it. Back tip DM chat-id resolution with ChatMemberDao.getChatIdForMember / ChatMemberDataSource.getChatIdForUser. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Run the two getDmChatFeed calls in parallel via coroutineScope/async so combined-feed latency is max(contact, tip) instead of their sum. Failure semantics are unchanged: a contact-feed failure is fatal, a tip-feed failure is tolerated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
bmc08gt
added a commit
that referenced
this pull request
Jul 24, 2026
…nt feed sync (#1123) * feat(chat): derive canonical DM chat IDs matching server Add ChatIdGenerator, which deterministically derives a DM's ChatId from the two participants' user IDs: SHA-256 over a per-type domain ("flipcash:chat:dm" for CONTACT_DM, "flipcash:chat:dm:2" for TIP_DM) and the unsigned-sorted, self-pair-collapsed member set. Mirrors the server's MustDeriveDmChatID byte-for-byte so either side reaches the same id without a prior lookup. Tests pin the wire-contract vectors (matching the iOS TipDmChatIDTests). * refactor(chat): extract DmChatResolver and add member accessors Split DM-identity resolution out of MessagingOperations into a dedicated DmChatResolver interface (generateChatId / getChatId), implemented by a new DmChatResolverDelegate and composed into RealChatCoordinator via `by` delegation. MessagingOperations is left focused on operating on an existing ChatId. Add MessagingOperations.getOtherMember(chatId), returning the full ChatMember (profile incl. avatar) with a local-cache-then-network fallback; getOtherMemberE164 now delegates to it. Back tip DM chat-id resolution with ChatMemberDao.getChatIdForMember / ChatMemberDataSource.getChatIdForUser. * perf(chat): fetch contact and tip DM feeds concurrently Run the two getDmChatFeed calls in parallel via coroutineScope/async so combined-feed latency is max(contact, tip) instead of their sum. Failure semantics are unchanged: a contact-feed failure is fatal, a tip-feed failure is tolerated. ---------
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.
Foundational chat-layer changes split out of the in-progress tip-DM / notifications work so they can land independently. Three focused commits:
1.
feat(chat)— canonical DM chat-id derivationAdds
ChatIdGenerator, deriving a DM'sChatIdfrom the two participants' user IDs: SHA-256 over a per-type domain (flipcash:chat:dmfor CONTACT_DM,flipcash:chat:dm:2for TIP_DM) and the unsigned-sorted, self-pair-collapsed member set. Mirrors the server'sMustDeriveDmChatIDbyte-for-byte, so either side reaches the same id without a prior lookup. Unit tests pin the wire-contract vectors (matching the iOSTipDmChatIDTests).2.
refactor(chat)— extractDmChatResolver, add member accessorsSplits DM-identity resolution out of
MessagingOperationsinto a dedicatedDmChatResolverinterface (generateChatId/getChatId), implemented by a newDmChatResolverDelegateand composed intoRealChatCoordinator.MessagingOperationsis left focused on operating on an existingChatId.Adds
MessagingOperations.getOtherMember(chatId)returning the fullChatMember(profile incl. avatar) with a local-cache-then-network fallback;getOtherMemberE164now delegates to it. Backs tip DM chat-id lookup withChatMemberDao.getChatIdForMember/ChatMemberDataSource.getChatIdForUser.3.
perf(chat)— concurrent feed syncRuns the contact and tip
getDmChatFeedcalls in parallel viacoroutineScope/async, so combined-feed latency ismax(contact, tip)instead of the sum. Failure semantics unchanged (contact fatal, tip tolerated).Testing
:apps:flipcash:shared:chat:testDebugUnitTestpasses (incl. newChatIdGeneratorTestcross-platform vectors).:apps:flipcash:shared:notifications:compileDebugKotlinpasses — existing callers ofgetOtherMemberE164are unaffected by the refactor.Notes
ChatCoordinatorfacade surface is unchanged; existinggetChatIdcallers still resolve through it.