messaging: owners can block a conversation

A blocked thread key is dropped unread (not announced, not counted against
the daily new-conversation limit). API, UI button with confirmation, and a
list with unblock.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
2026-11-18 20:50:38 +01:00
co-authored by Claude Sonnet 5.5
parent a54094ea35
commit 13c82f8d59
14 changed files with 433 additions and 3 deletions
+14
View File
@@ -141,6 +141,15 @@ CREATE TABLE IF NOT EXISTS inbox_seen (
hash TEXT PRIMARY KEY,
expires_at INTEGER NOT NULL
) WITHOUT ROWID;
-- Conversations the owner blocked: further envelopes of the thread are dropped
-- unread. Rows go when their listing does (see Expire).
CREATE TABLE IF NOT EXISTS inbox_blocked (
author TEXT NOT NULL,
listing_id TEXT NOT NULL,
thread TEXT NOT NULL,
blocked_at INTEGER NOT NULL,
PRIMARY KEY (author, listing_id, thread)
) WITHOUT ROWID;
-- The exact address of a listing, only ever read by its owner's node.
CREATE TABLE IF NOT EXISTS addresses (
author TEXT NOT NULL,
@@ -516,6 +525,11 @@ func (s *Store) Expire(ctx context.Context) (int64, error) {
if _, err := s.db.ExecContext(ctx, `DELETE FROM inbox_seen WHERE expires_at <= ?`, now); err != nil {
return n + m + k, err
}
if _, err := s.db.ExecContext(ctx, `
DELETE FROM inbox_blocked WHERE NOT EXISTS (
SELECT 1 FROM listings l WHERE l.author = inbox_blocked.author AND l.id = inbox_blocked.listing_id)`); err != nil {
return n + m + k, err
}
return n + m + k, nil
}