Files
buzz/crates
Wes 4704fbafb6 fix(relay): resurface a hidden DM when someone else messages it (#9678)
## Summary

A DM hidden with **Hide conversation** (kind 41012) stayed out of the
sidebar for good, even after new messages arrived. The only way back was
New message → same people → Send. This makes the relay clear the hide
when *another* member posts a message (kinds 9 / 40002 / 40008) in the
DM, like Slack does. The author's own hide is kept, so replying from
another device doesn't resurface it.

- `buzz-db` `dm.rs`: `unhide_dm_for_recipients` clears `hidden_at` for
every other active member. `lock_dm_visibility` takes the same advisory
lock that replacing the viewer's kind 30622 snapshot uses, then reads
that viewer's hidden DMs and latest snapshot time.
- `side_effects.rs`: `persist_dm_message` stores the message, clears the
hides and replaces each affected viewer's snapshot in **one
transaction**, then fans out after commit. A snapshot that doesn't land
rejects the message, so the client's resend tries again. When someone
hid the DM, the message takes the DM's membership lock before its
insert, as a removal does, so it can't deadlock against a removal or
reopen. The hide/open path (`publish_dm_visibility_snapshot`) shares the
same lock → read → write seam.
- Used by both message paths: client ingest (`ingest.rs`) and
relay-signed workflow messages (`workflow_sink.rs`, author resolved via
`effective_message_author`).
- `NIP-DV.md`: documents the rule.

**Deploy order:** relay first. The client companion is
block/buzz-app#3889, which rereads visibility from the writer when a
message lands in a hidden DM. Against an older client the row returns on
the next roster refresh.

### Related issue

N/A. None found.

### Testing

- New Postgres test `dm_message_from_someone_else_unhides_it`
(`membership_notice_postgres_tests.rs`): hide → the viewer's own message
keeps it hidden → a peer's message whose snapshot is blocked by a
trigger is rejected, not stored and not delivered → its resend, parked
at fan-out, already shows the DM visible and is delivered once. It is
`#[ignore]` (needs Postgres) and runs in Backend Integration CI. It was
not run locally.
- Pre-push `rust-tests` lane (`just test-unit`) and local clippy pass;
`observability_source` source-policy test updated for the new
transaction seam.
- Reviewed by the Royal Court agents. Their findings (atomicity,
lock-before-read, workflow path) are fixed in follow-up commits.
- Human test pending.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Wes <wesbillman@users.noreply.github.com>
Co-authored-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 10:21:17 -07:00
..