Migrate text payload to canonical posta.text/v1 wire shape #3
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "payload-canonical"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Server PR #28 stopped translating envelopes at the wire boundary and now passes the canonical
{kind, body}payload bytes to clients verbatim; migration v8 rewrote stored rows server-side. The server also rejectsPOST /messageswith400 bad-requestwhen the payload lacks a non-emptykind, so the iOS / Mac clients broke in both directions (inbound rendered as[unsupported message], outbound got 400'd).This PR brings the client onto the canonical
posta.text/v1wire shape, with a legacy fallback for rows already cached locally from before the server migration.What changed
TextPayloadreshape (PostaCore/MessageDTO.swift) —{kind: \"posta.text/v1\", body: String}. CustomDecoder:{kind, body}).{\"text\":\"…\"}when nokindis present so old local rows still render.kind(e.g.posta.link/v1) so they flow through to the[unsupported message]branch.{kind: \"posta.text/v1\", body: \"…\"}) so outboundPOST /messagespasses the server'skind-required check.PairedSessionView, iOSThreadView,SearchResultsView) — read.body; construct outbound viaTextPayload(body:).MessageDTO,Message,RawJSON,APIClientnow describe the canonical shape.{\"text\":\"hi\"}test payloads migrated to{\"kind\":\"posta.text/v1\",\"body\":\"hi\"}. New tests cover canonical-encode, wrong-kind rejection, legacy fallback, and the wire body ofPOST /messages.Contact-duplication fix
Server PR
b620964now republishescontact-changedas a side-effect of every inbound message.SyncReconciler.applyContactChangedmatched the existingContactrow byaccount.persistentModelID, which SwiftData's#Predicatedoesn't compare reliably across the captured-binding boundary — so every emission inserted a fresh duplicate. Aligning the predicate tocontact.account.url == accountURLmatches the pattern the GET/contactssync paths already use in both clients.Test plan
swift testpasses in PostaCore (102), PostaPersistence (23), PostaSync (35+), PostaTesting (27).contact-changedno longer duplicates contacts.