Expand description
Inbound processing: turn a verified, opened Community message into a Message
in STATE under its channel chat (→ app state). Pure conversion
(build_message) is separated from the STATE mutation (ingest_message) so the
conversion is unit-testable without any global state.
Enums§
- Incoming
Event - The result of processing an inbound wire event: a brand-new message (3300), an update to
an existing message (a reaction 3301 / edit 3302 applied to its target), or a tombstone
(a delete 3305 that removed its target). New/Updated surface as a UI
message_new/message_update; Removed surfaces as amessage_removed.
Functions§
- build_
message - event_
authenticates - Does this wire event authenticate against the channel’s keys — now (open +
MAC) or on a prior sight (dedup ledgers)? The outer
created_atis otherwise unauthenticated relay input: sync cursors must only ever advance over events that pass this, or one junk event stamped far-future/past at the channel’s cleartext pseudonym wedges the session’s fetch floor/ceiling. Ledger hits skip decryption, so steady-state re-syncs stay cheap. - ingest_
message - Ingest a verified Community message into STATE under its channel chat, creating
the chat (as
ChatType::Community) if absent. Returns the addedMessage(so the caller can persist + emit it), orNoneif it was a duplicate (dedup on the inner message id). - process_
channel_ batch - Process a fetched batch of raw channel events (backfill / cold-start) in a SAFE order:
messages (3300) first so a reaction/edit (3301/3302) finds its target already in STATE
before its reference applies — relay return order is arbitrary, and a control event whose
target hasn’t been ingested yet is silently dropped. Each event goes through
process_incoming(open + verify + dedup), so undecryptable/forged/duplicate events yield nothing. Returns the applied events in processing order for the caller to persist + emit. - process_
incoming - Open a single incoming wire event against
channel, verify the binding, and apply it to STATE by sub-kind: a message is ingested, a reaction/edit is applied to its target. Events that fail to open (wrong key, splice, forged sig, bad version) or that dedup/target-miss are dropped (returnsNone). This is the per-event handler the real-time subscription routes each arriving 3300/3301/3302 event through. - route_
incoming - Route an incoming wire event by its
zpseudonym tag to the matching channel inroutes, then open + ingest it. Returns the addedMessage, orNoneif the event carries noztag, names a pseudonym we don’t route, or fails to open/dedup. Pure over the passedstate+routes, so the routing is unit-testable without the live subscription loop.