Skip to content

feat(chat): add pin message contract scaffolding - #1884

Merged
bmc08gt merged 4 commits into
code/cashfrom
feat/chat-pins-contract
Oct 30, 2026
Merged

bmc08gt merged 4 commits into
code/cashfrom
feat/chat-pins-contract

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Data-layer scaffolding for chat pinned messages (flipcash2 contract 0.24.0, upstream #164). No UI.

Pins flipcash2-client-protocol to 0.24.0 (published from code-payments/flipcash2-client-protocol#32).

  • :services:flipcash: Pin, PinSummary, PinChange, PinsPage models. ChatMetadata.pinSummary, MetadataUpdate.PinsChanged, ViewerState.Permissions.canPin. pinMessage, unpinMessage, getPinnedMessages through ChatApi → ChatService → repository → ChatController, with PinMessageError, UnpinMessageError, GetPinnedMessagesError.
  • toMetadataUpdate() had an else that would have mapped pins_changed to LastActivityChanged(epoch 0). It now has an explicit PINS_CHANGED case.
  • Room 47 → 48 (AutoMigration): chat_metadata gains pin_count, pin_version and latest_pin (the serialized chat.v1.Pin), so the summary survives restarts and reads offline. Existing rows read as never pinned.
  • ChatMetadataDao enforces the merge as conditional UPDATEs on pin_version: a feed, GetChat or FullRefresh write replaces the stored summary only at an equal or higher version, and a write with no summary never clears it. observeById and the paged feed carry the summary from the row.
  • :apps:flipcash:shared:chat: EventStreamDelegate applies PinsChanged only when its version is greater than the stored one. A PinsChanged for a chat with no row is dropped; the next feed or GetChat supplies it.
  • PinSummary is no longer a data class: it carries the proto bytes of latest for storage, excluded from equality.
  • Tests: PinMappingTest and PinsChangedStreamTest are new; ChatMetadataDaoTest covers the merge, the BLOB round trip and a summary-less upsert keeping stored pins; FakeChatRepository gets the new methods.

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.
@bmc08gt bmc08gt self-assigned this Oct 29, 2026
@github-actions github-actions Bot added type: feature New functionality area: network gRPC, connectivity, API, exchange rates labels Oct 29, 2026
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.
@github-actions github-actions Bot added the area: build-system Gradle, convention plugins, build-logic label Oct 29, 2026
@bmc08gt
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
bmc08gt merged commit 3aa34f6 into code/cash Oct 30, 2026
6 checks passed
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: build-system Gradle, convention plugins, build-logic area: network gRPC, connectivity, API, exchange rates type: feature New functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant