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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user