fix: relay mark_unread to peers, fix docs and timestamp consistency

- Add queueReadStateRelay call in handleMarkUnread (skip '0' sentinel)
- Fix double Date.now() in queueReadStateRelay (use single const)
- Fix federation.md: read state relay uses outbox (not fire-and-forget),
  correct payload schema to match implementation
This commit is contained in:
Jannis Braun
2026-04-07 20:08:31 +02:00
parent 626a8ded50
commit 1ada46baff
3 changed files with 31 additions and 18 deletions
@@ -519,13 +519,14 @@ export function queueReadStateRelay(
messageRef = { sourceInstance: ourOrigin, sourceMessageId: messageId };
}
const now = Date.now();
const payload: FederationRelayEvent = {
eventType: 'read_state_update',
dmChannelId: channelId,
messageId: `read_state:${userId}:${Date.now()}`,
messageId: `read_state:${userId}:${now}`,
federatedId: channel.federatedId,
encryptionVersion: 0,
timestamp: Date.now(),
timestamp: now,
readState: {
user: { homeUserId, homeInstance },
messageRef,
+6
View File
@@ -1384,6 +1384,12 @@ function handleMarkUnread(event: Record<string, unknown>, userId: string, isFede
channelId,
messageId,
});
// Relay mark-unread to federated peers for cross-instance sync
// (skip the '0' sentinel — it deletes the read state and can't be mapped to a message)
if (messageId !== '0') {
queueReadStateRelay(channelId, messageId, userId);
}
}
// ─── DM Call Handlers (Unified Room API) ───────────────────────────────────