Repository navigation
feat(chat): add pin message contract scaffolding - #1884
Merged
Merged
Conversation
Wrap PinMessage, UnpinMessage and GetPinnedMessages through api, service, repository and controller with typed errors. Map Pin and PinSummary, Metadata.pin_summary, MetadataUpdate.pins_changed and ViewerState.Permissions.can_pin into the domain models. Data layer only; pins are not persisted or surfaced yet.
Hold each chat's PinSummary in memory in ChatMetadataDataSource, as iOS does. A server read with no summary or a lower version keeps the held one; an equal or higher version replaces it. PinsChanged applies only when strictly newer.
bmc08gt
marked this pull request as ready for review
October 29, 2026 23:14
Store each chat's pin summary on chat_metadata (pin_count, pin_version, latest_pin as the serialized chat.v1.Pin) so it survives restarts and reads offline. The merge and PinsChanged rules now run as conditional UPDATEs on pin_version, and the in-memory PinSummaryHolder is removed.
bmc08gt
added a commit
that referenced
this pull request
Oct 30, 2026
…ke-land * origin/code/cash: feat(payments): persist payment requests for offline (#1886) (#1892) feat(chat): add pin message contract scaffolding (#1884) # Conflicts: # apps/flipcash/shared/persistence/db/src/androidHostTest/kotlin/com/flipcash/app/persistence/dao/GroupKeyEnvelopeDaoTest.kt # apps/flipcash/shared/persistence/db/src/androidHostTest/kotlin/com/flipcash/app/persistence/dao/PaymentRequestDaoTest.kt # apps/flipcash/shared/persistence/db/src/commonMain/kotlin/com/flipcash/app/persistence/dao/GroupKeyEnvelopeDao.kt # apps/flipcash/shared/persistence/db/src/commonMain/kotlin/com/flipcash/app/persistence/dao/PaymentRequestDao.kt # apps/flipcash/shared/persistence/db/src/commonMain/kotlin/com/flipcash/app/persistence/entities/GroupKeyEnvelopeEntity.kt # apps/flipcash/shared/persistence/db/src/commonMain/kotlin/com/flipcash/app/persistence/entities/PaymentRequestEntity.kt # apps/flipcash/shared/persistence/sources/src/androidHostTest/kotlin/com/flipcash/app/persistence/sources/ChatRemovalDataTest.kt # apps/flipcash/shared/persistence/sources/src/commonMain/kotlin/com/flipcash/app/persistence/sources/GroupKeyEnvelopeDataSource.kt # apps/flipcash/shared/persistence/sources/src/commonMain/kotlin/com/flipcash/app/persistence/sources/PaymentRequestDataSource.kt # services/flipcash/src/androidHostTest/kotlin/com/flipcash/services/internal/network/extensions/PinMappingTest.kt # services/flipcash/src/androidHostTest/kotlin/com/flipcash/services/models/paymentrequest/PaymentRequestStorageTest.kt # services/flipcash/src/commonMain/kotlin/com/flipcash/services/chat/GroupKeyEnvelopeStore.kt # services/flipcash/src/commonMain/kotlin/com/flipcash/services/models/chat/Pin.kt # services/flipcash/src/commonMain/kotlin/com/flipcash/services/models/chat/PinSummaryStorage.kt # services/flipcash/src/commonMain/kotlin/com/flipcash/services/models/paymentrequest/PaymentRequestStorage.kt # services/flipcash/test-fixtures/src/commonMain/kotlin/com/flipcash/services/chat/InMemoryGroupKeyEnvelopeStore.kt
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.
Data-layer scaffolding for chat pinned messages (flipcash2 contract
0.24.0, upstream #164). No UI.Pins
flipcash2-client-protocolto0.24.0(published from code-payments/flipcash2-client-protocol#32).:services:flipcash:Pin,PinSummary,PinChange,PinsPagemodels.ChatMetadata.pinSummary,MetadataUpdate.PinsChanged,ViewerState.Permissions.canPin.pinMessage,unpinMessage,getPinnedMessagesthroughChatApi→ChatService→ repository →ChatController, withPinMessageError,UnpinMessageError,GetPinnedMessagesError.toMetadataUpdate()had anelsethat would have mappedpins_changedtoLastActivityChanged(epoch 0). It now has an explicitPINS_CHANGEDcase.47 → 48(AutoMigration):chat_metadatagainspin_count,pin_versionandlatest_pin(the serializedchat.v1.Pin), so the summary survives restarts and reads offline. Existing rows read as never pinned.ChatMetadataDaoenforces the merge as conditional UPDATEs onpin_version: a feed, GetChat orFullRefreshwrite replaces the stored summary only at an equal or higher version, and a write with no summary never clears it.observeByIdand the paged feed carry the summary from the row.:apps:flipcash:shared:chat:EventStreamDelegateappliesPinsChangedonly when its version is greater than the stored one. APinsChangedfor a chat with no row is dropped; the next feed or GetChat supplies it.PinSummaryis no longer a data class: it carries the proto bytes oflatestfor storage, excluded from equality.PinMappingTestandPinsChangedStreamTestare new;ChatMetadataDaoTestcovers the merge, the BLOB round trip and a summary-less upsert keeping stored pins;FakeChatRepositorygets the new methods.