mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-08 08:23:53 +01:00
Change threading context code to filter out blocked replies on view
This commit is contained in:
parent
f0716368e6
commit
2195bd5a90
1 changed files with 19 additions and 8 deletions
|
@ -73,15 +73,26 @@ module Status::ThreadingConcern
|
||||||
limit += 1 if limit.present?
|
limit += 1 if limit.present?
|
||||||
|
|
||||||
descendants_with_self = Status.find_by_sql([<<-SQL.squish, id: id, limit: limit, depth: depth])
|
descendants_with_self = Status.find_by_sql([<<-SQL.squish, id: id, limit: limit, depth: depth])
|
||||||
WITH RECURSIVE search_tree(id, path) AS (
|
WITH RECURSIVE search_tree(id, path, authors) AS (
|
||||||
SELECT id, ARRAY[id]
|
SELECT
|
||||||
FROM statuses
|
id, ARRAY[id], ARRAY[account_id]
|
||||||
WHERE id = :id
|
FROM
|
||||||
|
statuses
|
||||||
|
WHERE
|
||||||
|
id = :id
|
||||||
|
|
||||||
UNION ALL
|
UNION ALL
|
||||||
SELECT statuses.id, path || statuses.id
|
|
||||||
FROM search_tree
|
SELECT
|
||||||
JOIN statuses ON statuses.in_reply_to_id = search_tree.id
|
statuses.id, path || statuses.id, authors || statuses.account_id
|
||||||
WHERE COALESCE(array_length(path, 1) < :depth, TRUE) AND NOT statuses.id = ANY(path)
|
FROM
|
||||||
|
search_tree
|
||||||
|
JOIN
|
||||||
|
statuses ON statuses.in_reply_to_id = search_tree.id
|
||||||
|
WHERE
|
||||||
|
COALESCE(array_length(path, 1) < :depth, TRUE) AND NOT statuses.id = ANY(path)
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM blocks WHERE target_account_id = statuses.account_id AND account_id = any(authors))
|
||||||
|
AND NOT EXISTS (SELECT 1 FROM account_domain_blocks b JOIN accounts a ON a.domain = b.domain WHERE a.id = statuses.account_id AND b.account_id = any(authors))
|
||||||
)
|
)
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM search_tree
|
FROM search_tree
|
||||||
|
|
Loading…
Reference in a new issue