Sessions carry an owner; every chat route serves only the caller's own conversations (others are 404). Each turn and each approved held action acts as its owner's principal, checked against the access rules before judgement, so an operator's chat can't do what the operator can't. Chat is open to any signed-in person, and the stream sends chat updates only to the owner. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
16 lines
729 B
SQL
16 lines
729 B
SQL
-- +goose Up
|
|
-- A conversation belongs to the person who started it, and its turns act with
|
|
-- that person's access. Conversations from before ownership were the shared
|
|
-- administrator's, so they go to the system identity the admin token acts as.
|
|
ALTER TABLE chat.sessions ADD COLUMN owner_id text;
|
|
UPDATE chat.sessions SET owner_id = '00000000-0000-5000-8000-000000000001';
|
|
ALTER TABLE chat.sessions ALTER COLUMN owner_id SET NOT NULL;
|
|
|
|
DROP INDEX chat.sessions_by_org;
|
|
CREATE INDEX sessions_by_owner ON chat.sessions (org_id, owner_id, updated_at DESC);
|
|
|
|
-- +goose Down
|
|
DROP INDEX chat.sessions_by_owner;
|
|
CREATE INDEX sessions_by_org ON chat.sessions (org_id, updated_at DESC);
|
|
ALTER TABLE chat.sessions DROP COLUMN owner_id;
|