mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-07-21 02:20:03 +00:00
- Add channel_contacts migration (000014) with UNIQUE(channel_type, sender_id) - Add ContactStore interface with UPSERT, list, count, merge operations - Add ContactCollector with 30-min TTL cache to skip redundant DB writes - Wire auto-collection into gateway consumer on every inbound message - Add GET /v1/contacts API with pagination, search, channel_type & peer_kind filters - Rename Writers tab → Managers tab (UI-only; backend routes unchanged) - Extract InlineAddForm with scoped state, debounce cleanup, aria-expanded - Add Combobox contact picker with debounced search + auto-fill - Add Contacts page with server-side pagination, filters, i18n (en/vi/zh) - Add shared ChannelContact type, sidebar nav entry, route & query keys - Fix ILIKE wildcard escape, log CountContacts errors, extract shared type
23 lines
1.1 KiB
SQL
23 lines
1.1 KiB
SQL
-- Channel contacts: auto-collected user info from all channels.
|
|
-- Global (not per-agent). Used for contact selector, future RBAC, analytics.
|
|
CREATE TABLE IF NOT EXISTS channel_contacts (
|
|
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
channel_type VARCHAR(50) NOT NULL,
|
|
channel_instance VARCHAR(255),
|
|
sender_id VARCHAR(255) NOT NULL,
|
|
user_id VARCHAR(255),
|
|
display_name VARCHAR(255),
|
|
username VARCHAR(255),
|
|
avatar_url TEXT,
|
|
peer_kind VARCHAR(20),
|
|
metadata JSONB DEFAULT '{}',
|
|
merged_id UUID,
|
|
first_seen_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
last_seen_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
|
UNIQUE (channel_type, sender_id)
|
|
);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_channel_contacts_instance ON channel_contacts(channel_instance) WHERE channel_instance IS NOT NULL;
|
|
CREATE INDEX IF NOT EXISTS idx_channel_contacts_merged ON channel_contacts(merged_id) WHERE merged_id IS NOT NULL;
|
|
CREATE INDEX IF NOT EXISTS idx_channel_contacts_search ON channel_contacts(display_name, username);
|