Skip to content

Push a read event when a message is marked read - #55

Merged
markmnl merged 1 commit into
mainfrom
read-event
Oct 18, 2026
Merged

markmnl merged 1 commit into
mainfrom
read-event

Conversation

@markmnl

@markmnl markmnl commented Oct 17, 2026

Copy link
Copy Markdown
Owner

When a message is marked read, the reader's other tabs and devices learn about it over the WebSocket instead of showing it unread until they reload.

  • POST /fmsg/:id/read runs pg_notify('msg_read', '<id>,<reader>') the first time the message becomes read (not on repeat reads). This needs no schema change.
  • The hub LISTENs on msg_read and pushes {"type":"read","data":<message with read/time_read>} to the reader's connections.
  • The hub's channel switch moves into route(ctx, channel, msgID, addr) so routing can be unit tested; behaviour is unchanged for the existing channels.
  • README: adds the read event to the WebSocket events table, with a note under POST /fmsg/:id/read.

Tests: TestHubRoute_MsgReadPushesReadEvent (unit) and TestMarkReadNotifies (integration: one notification with the right payload; none on a repeat read). The full handler suite passes against Postgres 17.

Clients that don't know the read type ignore it, per the envelope contract.

🤖 Generated with Claude Code

POST /fmsg/:id/read now notifies msg_read the first time a message becomes
read, and the hub pushes a `read` event, carrying the message with its read
state, to all of the reader's WebSocket connections. A client open in another
tab or on another device can then stop showing the message as unread instead
of waiting for a reload.

The hub's channel switch moves into route so routing is unit tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@markmnl
markmnl merged commit 3054028 into main Oct 18, 2026
1 check passed
@markmnl
markmnl deleted the read-event branch October 18, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant