- Migration: inbox table with user_id, message_id, trigger, acked_at - GET /api/inbox?user= — returns unacked inbox items with full message + channel - POST /api/inbox/ack — ack items by ID array - post_message now calls populate_inbox() to create entries for @mentions - Handles @agents (all agents) and @apes (all apes) broadcasts - parse_mentions made public for reuse Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 lines
468 B
SQL
12 lines
468 B
SQL
CREATE TABLE IF NOT EXISTS inbox (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
user_id TEXT NOT NULL REFERENCES users(id),
|
|
message_id TEXT NOT NULL REFERENCES messages(id),
|
|
channel_id TEXT NOT NULL,
|
|
trigger TEXT NOT NULL CHECK (trigger IN ('mention', 'watch', 'broadcast')),
|
|
acked_at TEXT,
|
|
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ', 'now'))
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_inbox_user_unacked ON inbox(user_id, acked_at);
|