feat: add chat

This commit is contained in:
Krispire Admin
2026-08-29 03:49:30 +05:30
parent 3b10e726b7
commit d50031cdb3
21 changed files with 6960 additions and 11 deletions
+26
View File
@@ -0,0 +1,26 @@
-- Who may post in a group.
--
-- 'everyone' keeps existing groups behaving exactly as they do today, which is
-- why it is the default: this migration must not silently mute anyone.
-- 'admins' makes the thread an announcement channel — owners and admins post,
-- everyone else reads.
--
-- DMs and Kautilya threads ignore this: a two-party conversation has no
-- administrators, and the AI thread has one participant.
ALTER TABLE conversations
ADD COLUMN IF NOT EXISTS send_policy VARCHAR(8) NOT NULL DEFAULT 'everyone';
DO $$
BEGIN
IF NOT EXISTS (
SELECT 1 FROM pg_constraint WHERE conname = 'conversations_send_policy_check'
) THEN
ALTER TABLE conversations
ADD CONSTRAINT conversations_send_policy_check
CHECK (send_policy IN ('everyone', 'admins'));
END IF;
END $$;
-- "Who are this group's admins?" runs on every post in an admins-only thread.
CREATE INDEX IF NOT EXISTS conversation_participants_role_idx
ON conversation_participants (conversation_id, role) WHERE left_at IS NULL;