2004 lines · 51.7 KB · JSONRaw
{ "format_version": 1, "id": "thread", "name": "Chat", "plural": "Chats", "builtin": true, "visibility": "owner", "date": "last_message_at", "columns": [ { "key": "contact_id", "type": "link", "link_to": "message_contact", "readonly": true }, { "key": "kind", "type": "choice", "choices": [ "dm", "group" ], "labels": { "dm": "Direct", "group": "Group" }, "readonly": true }, { "key": "last_message_at", "name": "Last message", "type": "date", "readonly": true }, { "key": "last_message_preview", "name": "Last line", "type": "text", "readonly": true }, { "key": "archived", "type": "bool", "readonly": true }, { "key": "title", "name": "Title", "type": "text", "readonly": true }, { "key": "external_key", "type": "text", "readonly": true }, { "key": "photo_key", "name": "Photo", "type": "photo", "readonly": true }, { "key": "description", "type": "text", "readonly": true }, { "key": "created_by_phone", "type": "text", "readonly": true }, { "key": "read_seq", "type": "number", "readonly": true }, { "key": "delivered_seq", "type": "number", "readonly": true }, { "key": "muted_until", "name": "Muted until", "type": "date" }, { "key": "pinned_at", "name": "Pinned", "type": "date" }, { "key": "unread_marked_at", "type": "date", "format": "calendar-datetime", "readonly": true }, { "key": "draft", "type": "text", "readonly": true }, { "key": "draft_reply_to_id", "type": "text", "readonly": true }, { "key": "cleared_before", "type": "date", "format": "calendar-datetime", "readonly": true }, { "key": "summary", "type": "longtext" }, { "key": "summary_updated_at", "type": "date", "format": "calendar-datetime", "readonly": true }, { "key": "summary_by", "type": "text", "readonly": true }, { "key": "trashed_at", "type": "date", "format": "calendar-datetime", "readonly": true }, { "key": "name", "name": "Name", "type": "text", "readonly": true }, { "key": "members", "type": "longtext", "readonly": true }, { "key": "member_people", "name": "People", "type": "link", "link_to": "person", "readonly": true, "multiple": true, "plain_before": "member_self", "plain_after": "members_unmatched" }, { "key": "member_self", "type": "text", "readonly": true }, { "key": "members_unmatched", "type": "longtext", "readonly": true }, { "key": "channels", "type": "text", "readonly": true, "fact": true, "reading": "{value}" }, { "key": "state_line", "type": "text", "readonly": true }, { "key": "unread", "name": "Unread", "type": "choice", "choices": [ "read", "unread" ], "readonly": true, "labels": { "read": "Read", "unread": "Unread" } }, { "key": "pinned", "type": "bool", "readonly": true }, { "key": "muted", "type": "bool", "readonly": true }, { "key": "fileable", "type": "bool", "readonly": true }, { "key": "filed", "type": "text", "readonly": true }, { "key": "filed_in", "name": "Filed in", "type": "text", "readonly": true }, { "key": "filed_copy", "type": "bool", "readonly": true }, { "key": "sendable", "name": "Can send", "type": "bool", "readonly": true }, { "key": "send_blocked_reason", "name": "Why it cannot send", "type": "text", "readonly": true } ], "instructions": "A chat is one imported WhatsApp, Instagram, iMessage or SMS conversation, direct or group. The owner's own app can reply through a linked WhatsApp number or the exact live Instagram account and thread read by their Mac; an export alone supplies no Instagram reply address. sendable says whether this chat can send, send_blocked_reason why not; an assistant never sends. In a shared database a chat is a filed copy (filed_copy): everybody there reads it, nobody sends into it, and pinning, muting, archiving or clearing it changes the copy for everyone there and nothing in the Messages it was filed from. Its name is the person's or the contact's for a direct chat, the title for a group. The chat carries project membership for its messages. The summary is a short account of the conversation; keep it to what the messages say.", "tables": [ { "name": "cotton_msg_owner_settings", "columns": [ { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n workspace_id TEXT PRIMARY KEY", "position": 0 }, { "name": "handle", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n handle TEXT NOT NULL", "position": 1 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n display_name TEXT NOT NULL", "position": 2 }, { "name": "avatar_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_url TEXT", "position": 3 }, { "name": "availability_copy", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n availability_copy TEXT", "position": 4 }, { "name": "allow_new_contacts", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n allow_new_contacts INTEGER NOT NULL DEFAULT 1", "position": 5 }, { "name": "app_download_url", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n app_download_url TEXT", "position": 6 }, { "name": "read_receipts", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n read_receipts INTEGER NOT NULL DEFAULT 1", "position": 7 }, { "name": "discoverable", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n discoverable INTEGER NOT NULL DEFAULT 1", "position": 8 }, { "name": "last_seen_visible", "type": "INTEGER", "default": "1", "nullable": false, "primary_key": false, "declaration": "\n last_seen_visible INTEGER NOT NULL DEFAULT 1", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "share_requests", "type": "TEXT", "default": "'contacts_direct'", "nullable": false, "primary_key": false, "declaration": " share_requests TEXT NOT NULL DEFAULT 'contacts_direct' CHECK (share_requests IN ('contacts_direct','ask_always'))", "position": 13 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n CHECK (handle NOT IN ('inbox', 'api', 'assets', 'admin', 'settings', 'download', 'privacy', 'terms', 'about', 'app', 'm'))", "position": 15 }, { "declaration": "\n CHECK (length(handle) BETWEEN 3 AND 30 AND NOT handle GLOB '*[^a-z0-9-]*')", "position": 16 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 17 } ], "prefix": "CREATE TABLE cotton_msg_owner_settings (", "suffix": ")", "indexes": [ "CREATE UNIQUE INDEX uq_cotton_msg_owner_settings_handle ON cotton_msg_owner_settings (handle)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_owner_settings_author ON cotton_msg_owner_settings (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_reactions", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "message_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n message_id TEXT NOT NULL", "position": 3 }, { "name": "actor", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n actor TEXT NOT NULL", "position": 4 }, { "name": "emoji", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n emoji TEXT NOT NULL", "position": 5 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 } ], "constraints": [ { "declaration": "\n UNIQUE (message_id, actor)", "position": 9 }, { "declaration": "\n CHECK (trim(actor) <> '')", "position": 10 }, { "declaration": "\n CHECK (trim(emoji) <> '' AND length(emoji) <= 8)", "position": 11 }, { "declaration": "\n FOREIGN KEY (message_id) REFERENCES cotton_msg_messages(id)", "position": 12 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE cotton_msg_reactions (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_reactions_message ON cotton_msg_reactions (message_id)", "CREATE INDEX idx_cotton_msg_reactions_workspace ON cotton_msg_reactions (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_reactions_author ON cotton_msg_reactions (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_threads", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n contact_id TEXT", "position": 2 }, { "name": "kind", "type": "TEXT", "default": "'dm'", "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL DEFAULT 'dm'", "position": 3 }, { "name": "last_message_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_message_at TEXT", "position": 4 }, { "name": "last_message_preview", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n last_message_preview TEXT", "position": 5 }, { "name": "archived", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n archived INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 7 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 8 }, { "name": "title", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n title TEXT", "position": 9 }, { "name": "external_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n external_key TEXT", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "photo_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " photo_key TEXT", "position": 12 }, { "name": "description", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " description TEXT", "position": 13 }, { "name": "created_by_phone", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " created_by_phone TEXT", "position": 14 }, { "name": "read_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " read_seq INTEGER NOT NULL DEFAULT 0", "position": 15 }, { "name": "delivered_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": " delivered_seq INTEGER NOT NULL DEFAULT 0", "position": 16 }, { "name": "muted_until", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " muted_until TEXT", "position": 17 }, { "name": "pinned_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " pinned_at TEXT", "position": 18 }, { "name": "unread_marked_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " unread_marked_at TEXT", "position": 19 }, { "name": "draft", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " draft TEXT", "position": 20 }, { "name": "draft_reply_to_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " draft_reply_to_id TEXT", "position": 21 }, { "name": "cleared_before", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " cleared_before TEXT", "position": 22 }, { "name": "summary", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " summary TEXT CHECK ((summary IS NULL) OR (length(summary) <= 4000))", "position": 23 }, { "name": "summary_updated_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " summary_updated_at TEXT", "position": 24 }, { "name": "summary_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": " summary_by TEXT CHECK ((summary_by IS NULL) OR (length(trim(summary_by)) > 0))", "position": 25 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 26 }, { "name": "trashed_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n trashed_at TEXT", "position": 27 } ], "constraints": [ { "declaration": "\n CHECK (kind IN ('dm', 'group'))", "position": 28 }, { "declaration": "\n CHECK (((kind = 'dm') AND ((contact_id IS NOT NULL) OR (NULLIF(trim(COALESCE(title, '')), '') IS NOT NULL))) OR ((kind = 'group') AND (contact_id IS NULL) AND (NULLIF(trim(COALESCE(title, '')), '') IS NOT NULL)))", "position": 29 }, { "declaration": "\n FOREIGN KEY (contact_id) REFERENCES cotton_msg_contacts(id)", "position": 30 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 31 } ], "prefix": "CREATE TABLE \"cotton_msg_threads\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_threads_contact ON cotton_msg_threads (contact_id)", "CREATE INDEX idx_cotton_msg_threads_workspace_recent ON cotton_msg_threads (workspace_id, last_message_at DESC)", "CREATE UNIQUE INDEX uq_cotton_msg_threads_dm ON cotton_msg_threads (workspace_id, contact_id) WHERE kind = 'dm'", "CREATE UNIQUE INDEX uq_cotton_msg_threads_group_key ON cotton_msg_threads (workspace_id, external_key) WHERE external_key IS NOT NULL", "CREATE INDEX idx_cotton_msg_threads_pinned ON cotton_msg_threads (workspace_id, pinned_at) WHERE pinned_at IS NOT NULL", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_threads_author ON cotton_msg_threads (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_contacts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "phone_e164", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n phone_e164 TEXT", "position": 2 }, { "name": "display_name", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n display_name TEXT", "position": 3 }, { "name": "person_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n person_id TEXT", "position": 4 }, { "name": "auth_user_id", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n auth_user_id TEXT", "position": 5 }, { "name": "vip", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n vip INTEGER NOT NULL DEFAULT 0", "position": 6 }, { "name": "muted", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n muted INTEGER NOT NULL DEFAULT 0", "position": 7 }, { "name": "blocked", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n blocked INTEGER NOT NULL DEFAULT 0", "position": 8 }, { "name": "on_cotton_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n on_cotton_at TEXT", "position": 9 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 10 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 11 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 12 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 13 }, { "name": "avatar_key", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n avatar_key TEXT", "position": 14 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, phone_e164)", "position": 15 }, { "declaration": "\n CHECK (phone_e164 IS NULL OR (length(phone_e164) BETWEEN 8 AND 15 AND NOT phone_e164 GLOB '*[^0-9]*'))", "position": 16 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 17 } ], "prefix": "CREATE TABLE \"cotton_msg_contacts\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_contacts_auth_user ON cotton_msg_contacts (auth_user_id) WHERE auth_user_id IS NOT NULL", "CREATE INDEX idx_cotton_msg_contacts_workspace ON cotton_msg_contacts (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_contacts_author ON cotton_msg_contacts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_receipts", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "phone", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n phone TEXT NOT NULL", "position": 3 }, { "name": "delivered_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n delivered_seq INTEGER NOT NULL DEFAULT 0", "position": 4 }, { "name": "read_seq", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n read_seq INTEGER NOT NULL DEFAULT 0", "position": 5 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 6 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 7 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 8 } ], "constraints": [ { "declaration": "\n UNIQUE (thread_id, phone)", "position": 9 }, { "declaration": "\n CHECK ((length(phone) BETWEEN 8 AND 15 AND NOT phone GLOB '*[^0-9]*') OR (length(phone) BETWEEN 2 AND 31 AND phone GLOB '[a-z0-9]*' AND NOT phone GLOB '*[^a-z0-9-]*' AND phone GLOB '*[^0-9]*'))", "position": 10 }, { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 11 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 12 } ], "prefix": "CREATE TABLE \"cotton_msg_receipts\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_receipts_thread ON cotton_msg_receipts (thread_id)", "CREATE INDEX idx_cotton_msg_receipts_workspace ON cotton_msg_receipts (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_receipts_author ON cotton_msg_receipts (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_contact_handles", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "contact_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n contact_id TEXT NOT NULL", "position": 2 }, { "name": "kind", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n kind TEXT NOT NULL", "position": 3 }, { "name": "value", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n value TEXT NOT NULL", "position": 4 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 5 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 6 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 7 } ], "constraints": [ { "declaration": "\n UNIQUE (workspace_id, kind, value)", "position": 8 }, { "declaration": "\n CHECK (kind IN ('phone', 'email', 'cotton', 'instagram', 'facebook', 'linkedin'))", "position": 9 }, { "declaration": "\n CHECK (kind <> 'phone' OR (length(value) BETWEEN 8 AND 15 AND NOT value GLOB '*[^0-9]*'))", "position": 10 }, { "declaration": "\n CHECK (kind <> 'email' OR (value = lower(value) AND value LIKE '%_@_%' AND value NOT GLOB '* *'))", "position": 11 }, { "declaration": "\n CHECK (kind <> 'cotton' OR (length(value) BETWEEN 2 AND 31 AND value GLOB '[a-z0-9]*' AND NOT value GLOB '*[^a-z0-9-]*' AND value GLOB '*[^0-9]*'))", "position": 12 }, { "declaration": "\n FOREIGN KEY (contact_id) REFERENCES cotton_msg_contacts(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE \"cotton_msg_contact_handles\" (", "suffix": ")", "indexes": [ "CREATE INDEX idx_cotton_msg_contact_handles_contact ON cotton_msg_contact_handles (contact_id)", "CREATE INDEX idx_cotton_msg_contact_handles_workspace ON cotton_msg_contact_handles (workspace_id)", "CREATE INDEX IF NOT EXISTS idx_cotton_msg_contact_handles_author ON cotton_msg_contact_handles (substr(_hlc, 20), _hlc)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_thread_filings", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL", "position": 2 }, { "name": "database_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n database_id TEXT NOT NULL CHECK (length(trim(database_id)) > 0)", "position": 3 }, { "name": "state", "type": "TEXT", "default": "'filed'", "nullable": false, "primary_key": false, "declaration": "\n state TEXT NOT NULL DEFAULT 'filed' CHECK (state IN ('filed','paused','unfiled'))", "position": 4 }, { "name": "paused_by", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n paused_by TEXT", "position": 5 }, { "name": "copied_through", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n copied_through TEXT", "position": 6 }, { "name": "filed_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n filed_at TEXT NOT NULL", "position": 7 }, { "name": "unfiled_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n unfiled_at TEXT", "position": 8 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 9 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 10 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 11 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 12 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (thread_id) REFERENCES cotton_msg_threads(id)", "position": 13 }, { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 14 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_msg_thread_filings (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_msg_thread_filings_author ON cotton_msg_thread_filings (substr(_hlc, 20), _hlc)", "CREATE UNIQUE INDEX uq_cotton_msg_thread_filings_pair ON cotton_msg_thread_filings (workspace_id, thread_id, database_id)", "CREATE INDEX idx_cotton_msg_thread_filings_state ON cotton_msg_thread_filings (workspace_id, state)" ], "full_text": [], "triggers": [] }, { "name": "cotton_msg_thread_marks", "columns": [ { "name": "id", "type": "TEXT", "default": null, "nullable": true, "primary_key": true, "declaration": "\n id TEXT PRIMARY KEY", "position": 0 }, { "name": "workspace_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n workspace_id TEXT NOT NULL", "position": 1 }, { "name": "database_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n database_id TEXT NOT NULL CHECK (length(trim(database_id)) > 0)", "position": 2 }, { "name": "thread_id", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n thread_id TEXT NOT NULL CHECK (length(trim(thread_id)) > 0)", "position": 3 }, { "name": "pinned_at", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n pinned_at TEXT", "position": 4 }, { "name": "muted_until", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n muted_until TEXT", "position": 5 }, { "name": "archived", "type": "INTEGER", "default": "0", "nullable": false, "primary_key": false, "declaration": "\n archived INTEGER NOT NULL DEFAULT 0 CHECK (archived IN (0,1))", "position": 6 }, { "name": "cleared_before", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n cleared_before TEXT", "position": 7 }, { "name": "created_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n created_at TEXT NOT NULL", "position": 8 }, { "name": "updated_at", "type": "TEXT", "default": null, "nullable": false, "primary_key": false, "declaration": "\n updated_at TEXT NOT NULL", "position": 9 }, { "name": "_hlc", "type": "TEXT", "default": "''", "nullable": false, "primary_key": false, "declaration": "\n _hlc TEXT NOT NULL DEFAULT ''", "position": 10 }, { "name": "_born", "type": "TEXT", "default": null, "nullable": true, "primary_key": false, "declaration": "\n _born TEXT", "position": 11 } ], "constraints": [ { "declaration": "\n FOREIGN KEY (workspace_id) REFERENCES cotton_workspaces(id) ON DELETE CASCADE\n ", "position": 12 } ], "prefix": "CREATE TABLE IF NOT EXISTS cotton_msg_thread_marks (", "suffix": ")", "indexes": [ "CREATE INDEX IF NOT EXISTS idx_cotton_msg_thread_marks_author ON cotton_msg_thread_marks (substr(_hlc, 20), _hlc)", "CREATE UNIQUE INDEX uq_cotton_msg_thread_marks_copy ON cotton_msg_thread_marks (workspace_id, database_id, thread_id)" ], "full_text": [], "triggers": [] } ], "picture": { "photo": "photo:9713719602098b4534d4aa3d950031eac5a813fc66fa11de8027b29ec5cd4f9d", "object": "tool-messages" }, "engine": "messages", "title": "name", "project": null, "order": null, "slip": { "title": "name", "subtitle": "last_message_preview", "trailing": "last_message_at", "photo": "photo_key", "toggle": null, "unread": "unread", "status": "state_line" }, "tile": { "face": "slip-list", "current": { "column": "last_message_at", "days": 2 } }, "page": [ { "heading": null, "columns": [ "photo_key", "description" ] }, { "heading": "Summary", "columns": [ "summary", "summary_by" ] }, { "heading": null, "columns": [ "member_people" ], "when": { "column": "members", "present": true } }, { "heading": "About", "columns": [ "channels", "filed_in" ] } ], "page_parts": [ "title", "facts", "messages" ], "archived": "archived", "add": false, "record_route": "/messages/[thread]", "sort": { "column": "pinned_at", "descending": true, "tie": "last_message_at" }, "conversation": { "table": "message", "links": [ "thread_id" ], "body": "display_body", "at": "sent_at", "mine": { "column": "direction", "values": [ "out" ] }, "header": [ "sender_label", "reply_preview" ], "footer": [ "reactions", "edited_label", "starred_label", "provenance", "shared_status" ], "media": "media", "system": "is_system", "color_by": "paper_sender", "queue": { "link": "thread_id", "body": "body" }, "photo": "sender_photo", "can_send": "sendable", "placeholder": "Reply…" }, "composer": true, "delete": false, "menu": [ { "label": "Import chat", "path": "/messages/import", "object": "file" } ], "related": [ { "label": "Archived chats", "table": "thread", "filter": { "archived": true }, "archived": true, "title": "Archived chats", "empty": { "title": "Nothing archived", "message": "A chat you archive leaves the list and is kept here." } }, { "label": "Members", "table": "thread_member", "column": "thread_id", "when": { "kind": "group" } }, { "label": "Kept messages", "table": "message", "filter": { "kept": true }, "open": "thread_id", "title": "Kept messages", "empty": { "title": "Nothing kept yet", "message": "A message you keep is listed here, and opens in its chat." } }, { "label": "Search all messages", "table": "message", "open": "thread_id", "title": "All messages" } ], "commands": [ { "id": "read", "label": "Mark read", "kind": "update", "verb": "mark_thread_read", "bindings": { "threadId": "$id" } }, { "id": "pin", "label": "Pin", "kind": "update", "verb": "set_thread_pinned", "data": { "pinned": true }, "bindings": { "threadId": "$id" }, "when": { "pinned": false }, "receipt": "Pinned", "undo": "unpin", "object": "pushpin" }, { "id": "unpin", "label": "Unpin", "kind": "update", "verb": "set_thread_pinned", "data": { "pinned": false }, "bindings": { "threadId": "$id" }, "when": { "pinned": true }, "receipt": "Unpinned", "undo": "pin", "object": "pushpin" }, { "id": "mute", "label": "Mute", "kind": "update", "verb": "set_thread_muted", "data": { "until": "9999-12-31T00:00:00Z" }, "bindings": { "threadId": "$id" }, "when": { "muted": false }, "receipt": "Muted", "undo": "unmute", "does": "puts-away", "object": "muted" }, { "id": "unmute", "label": "Unmute", "kind": "update", "verb": "set_thread_muted", "data": {}, "bindings": { "threadId": "$id" }, "when": { "muted": true }, "receipt": "Unmuted", "undo": "mute", "object": "bell" }, { "id": "archive", "label": "Archive", "kind": "update", "verb": "set_thread_archived", "data": { "archived": true }, "bindings": { "threadId": "$id" }, "when": { "archived": false }, "receipt": "Archived", "undo": "unarchive", "does": "puts-away", "object": "archive" }, { "id": "unarchive", "label": "Unarchive", "kind": "update", "verb": "set_thread_archived", "data": { "archived": false }, "bindings": { "threadId": "$id" }, "when": { "archived": true }, "receipt": "Moved {name} back to your chats", "undo": "archive", "object": "restore" }, { "id": "clear", "label": "Clear chat", "kind": "update", "verb": "clear_thread", "destructive": true, "confirm": "Every message in this chat up to now leaves your copy of it. The chat stays in the list, and nobody else's copy changes. This cannot be undone.", "bindings": { "threadId": "$id" }, "receipt": "Chat cleared", "does": "destroys" }, { "id": "file", "label": "File", "kind": "update", "method": "messages.fileThread", "bindings": { "thread": "$id" }, "when": { "fileable": true }, "receipt": "Filed {name} in {picked}", "undo": "unfile", "pick": { "argument": "database", "kind": "database" }, "does": "moves" }, { "id": "unfile", "label": "Unfile", "kind": "update", "method": "messages.unfileThread", "bindings": { "thread": "$id" }, "when": { "filed": "one" }, "receipt": "Unfiled {name}", "undo": "file", "object": "move" } ], "on_open": "read", "views": [ { "face": "chats", "name": "Recent chats" } ], "card": { "face": "thread.slips", "fields": [ { "slot": "title", "column": "name" }, { "slot": "photo", "column": "photo_key" }, { "slot": "subtitle", "column": "state_line" }, { "slot": "body", "column": "last_message_preview" }, { "slot": "date", "column": "last_message_at", "form": "weekday_date" }, { "slot": "unread", "column": "unread", "only": [ "unread" ] }, { "slot": "people", "column": "member_people", "max": 3 } ], "offers": [ "thread.slips", "thread" ] }, "tool": { "views": [ { "id": "all", "label": "All", "visibility": "owner", "is_default": true, "read": { "table": "thread" } }, { "id": "whatsapp", "label": "WhatsApp", "visibility": "owner", "is_default": false, "read": { "table": "thread", "where": { "channels": "whatsapp" } } }, { "id": "sms", "label": "SMS", "visibility": "owner", "is_default": false, "read": { "table": "thread", "where": { "channels": "sms" } } }, { "id": "instagram", "label": "Instagram", "visibility": "owner", "is_default": false, "read": { "table": "thread", "where": { "channels": "instagram" } } }, { "id": "starred", "label": "Starred", "visibility": "owner", "is_default": false, "read": { "table": "message", "where": { "starred_at": { "present": true } } }, "sort": { "column": "starred_at", "descending": true }, "face": "cards", "card": { "face": "message", "fields": [ { "slot": "photo", "column": "sender_photo" }, { "slot": "title", "column": "sender_label" }, { "slot": "body", "column": "display_body" }, { "slot": "date", "column": "sent_at", "form": "weekday_date" }, { "slot": "source", "column": "channel" } ] } }, { "id": "agents", "label": "Agents", "visibility": "owner", "is_default": false, "read": { "table": "session" }, "sort": { "column": "active_at", "descending": true }, "face": "cards" } ], "name": "Messages", "purpose": "Your conversations and the files shared in them.", "key": "messages", "icon": "message-square", "card_stock": "rose", "route": "/messages", "figures": [ { "read": "unreadMessages", "many": "{n} unread" } ] }, "parts": { "shape": "desk", "head": { "facts": [ "channels" ], "state": "kind" }, "links": [], "body": "summary", "lists": [], "acts": { "more": [ "pin", "unpin", "mute", "unmute", "archive", "unarchive", "file", "unfile" ], "away": "clear" }, "strip": [ { "column": "members", "when": { "column": "kind", "values": [ "group" ] } }, { "column": "state_line" }, { "column": "filed_in" } ], "opens": "facts" }}