mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
refactor: remove bot type
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
SELECT
|
||||
b.id AS id,
|
||||
b.id AS bot_id,
|
||||
(COALESCE(NULLIF(sqlc.arg(kind)::text, ''), CASE WHEN b.type = 'public' THEN 'group' ELSE 'direct' END))::text AS kind,
|
||||
(COALESCE(NULLIF(sqlc.arg(kind)::text, ''), 'direct'))::text AS kind,
|
||||
CASE WHEN sqlc.arg(kind) = 'thread' THEN sqlc.arg(parent_chat_id)::uuid ELSE NULL::uuid END AS parent_chat_id,
|
||||
COALESCE(NULLIF(sqlc.arg(title)::text, ''), b.display_name) AS title,
|
||||
COALESCE(sqlc.arg(created_by_user_id)::uuid, b.owner_user_id) AS created_by_user_id,
|
||||
@@ -19,7 +19,7 @@ LIMIT 1;
|
||||
SELECT
|
||||
b.id AS id,
|
||||
b.id AS bot_id,
|
||||
CASE WHEN b.type = 'public' THEN 'group' ELSE 'direct' END AS kind,
|
||||
'direct'::text AS kind,
|
||||
NULL::uuid AS parent_chat_id,
|
||||
b.display_name AS title,
|
||||
b.owner_user_id AS created_by_user_id,
|
||||
@@ -35,7 +35,7 @@ WHERE b.id = $1;
|
||||
SELECT
|
||||
b.id AS id,
|
||||
b.id AS bot_id,
|
||||
CASE WHEN b.type = 'public' THEN 'group' ELSE 'direct' END AS kind,
|
||||
'direct'::text AS kind,
|
||||
NULL::uuid AS parent_chat_id,
|
||||
b.display_name AS title,
|
||||
b.owner_user_id AS created_by_user_id,
|
||||
@@ -53,7 +53,7 @@ ORDER BY b.updated_at DESC;
|
||||
SELECT
|
||||
b.id AS id,
|
||||
b.id AS bot_id,
|
||||
CASE WHEN b.type = 'public' THEN 'group' ELSE 'direct' END AS kind,
|
||||
'direct'::text AS kind,
|
||||
NULL::uuid AS parent_chat_id,
|
||||
b.display_name AS title,
|
||||
b.owner_user_id AS created_by_user_id,
|
||||
@@ -64,7 +64,7 @@ SELECT
|
||||
'participant'::text AS access_mode,
|
||||
(CASE
|
||||
WHEN b.owner_user_id = sqlc.arg(user_id) THEN 'owner'
|
||||
ELSE COALESCE(bm.role, ''::text)
|
||||
ELSE ''::text
|
||||
END)::text AS participant_role,
|
||||
NULL::timestamptz AS last_observed_at
|
||||
FROM bots b
|
||||
@@ -87,7 +87,7 @@ LIMIT 1;
|
||||
SELECT
|
||||
b.id AS id,
|
||||
b.id AS bot_id,
|
||||
CASE WHEN b.type = 'public' THEN 'group' ELSE 'direct' END AS kind,
|
||||
'direct'::text AS kind,
|
||||
NULL::uuid AS parent_chat_id,
|
||||
b.display_name AS title,
|
||||
b.owner_user_id AS created_by_user_id,
|
||||
@@ -111,7 +111,7 @@ WITH updated AS (
|
||||
SELECT
|
||||
updated.id AS id,
|
||||
updated.id AS bot_id,
|
||||
CASE WHEN updated.type = 'public' THEN 'group' ELSE 'direct' END AS kind,
|
||||
'direct'::text AS kind,
|
||||
NULL::uuid AS parent_chat_id,
|
||||
updated.display_name AS title,
|
||||
updated.owner_user_id AS created_by_user_id,
|
||||
|
||||
Reference in New Issue
Block a user