cipher/migrations/0004_group_invites.sql
King Omar 726d9d53ba Add read receipts, disappearing messages, and group invite links
Receipts: messages now carry a shared client id (mid); recipients send
delivered/read receipts over the E2E relay, rendered as ✓/✓✓ ticks (blue
when read). Groups aggregate — ticks turn on once every member acks.

Disappearing messages: per-chat timer (Off..1 week) stored locally and
synced to peers via an encrypted config control message; messages carry a
ttl and a client-side sweeper deletes them from both sides on schedule.

Group invite links: new group_invites table + /groups/:id/invite (mint/
revoke) and /groups/join routes. Group info gains "Add people" and
"Invite via link" (shareable URL + QR); opening a #join=<token> link joins
the group and re-syncs every member's roster over the relay.

store.js v3 adds a mid index + getByMid/put/sweepExpired; SW cache v9.
Verified: 12 live server tests (invite/join/add/revoke/leave) + 11
store unit tests (receipts, sweep, meta) all green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-22 18:32:24 +10:00

11 lines
539 B
SQL

-- Shareable group invite links. A token is a bearer capability: anyone with an
-- account who has the link can join the group. Revoke by deleting the row(s).
-- The server still only ever holds group METADATA — message content stays E2E.
CREATE TABLE group_invites (
token TEXT PRIMARY KEY,
group_id TEXT NOT NULL REFERENCES groups(id) ON DELETE CASCADE,
created_by TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
created_at INTEGER NOT NULL
);
CREATE INDEX idx_group_invites_group ON group_invites(group_id);