fix: scope combined chat source filters (#26137)

This commit is contained in:
Danielle Maywood
2026-06-08 15:05:27 +01:00
committed by GitHub
parent 9db70b6ec8
commit d751b46a19
17 changed files with 167 additions and 76 deletions
+8 -9
View File
@@ -481,19 +481,18 @@ SELECT
FROM
chats_expanded
WHERE
CASE
WHEN @owned_only::boolean THEN chats_expanded.owner_id = @viewer_id::uuid
ELSE true
END
AND CASE
WHEN @shared_only::boolean THEN
chats_expanded.owner_id != @viewer_id::uuid
(
(NOT @owned_only::boolean AND NOT @shared_only::boolean)
OR (@owned_only::boolean AND chats_expanded.owner_id = @viewer_id::uuid)
OR (
@shared_only::boolean
AND chats_expanded.owner_id != @viewer_id::uuid
AND (
chats_expanded.user_acl ? (@shared_with_user_id::uuid)::text
OR chats_expanded.group_acl ?| @shared_with_group_ids::text[]
)
ELSE true
END
)
)
AND CASE
WHEN sqlc.narg('archived') :: boolean IS NULL THEN true
ELSE chats_expanded.archived = sqlc.narg('archived') :: boolean