feat(api,userbot,frontend): search peers without chats and start tracking them
This commit is contained in:
@@ -56,7 +56,9 @@ async def list_chats(
|
||||
rows = await pool.fetch(
|
||||
"WITH ids AS ("
|
||||
"SELECT DISTINCT chat_id FROM messages WHERE account_id = $1 "
|
||||
"UNION SELECT chat_id FROM dialogs WHERE account_id = $1), "
|
||||
"UNION SELECT chat_id FROM dialogs WHERE account_id = $1 "
|
||||
"UNION SELECT scope_id FROM capture_policy WHERE account_id = $1 "
|
||||
"AND scope_type = 'chat' AND scope_id IS NOT NULL), "
|
||||
"agg AS (SELECT chat_id, count(*) AS message_count, max(date) AS last_date "
|
||||
"FROM messages WHERE account_id = $1 GROUP BY chat_id) "
|
||||
"SELECT ids.chat_id, COALESCE(agg.message_count, 0) AS message_count, "
|
||||
|
||||
Reference in New Issue
Block a user