mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-23 13:05:12 +01:00
Fix response_to_recipient? CTE (#17427)
This commit is contained in:
parent
d1ecc323e7
commit
948235592a
@ -73,9 +73,11 @@ class NotifyService < BaseService
|
|||||||
|
|
||||||
# Using an SQL CTE to avoid unneeded back-and-forth with SQL server in case of long threads
|
# Using an SQL CTE to avoid unneeded back-and-forth with SQL server in case of long threads
|
||||||
!Status.count_by_sql([<<-SQL.squish, id: @notification.target_status.in_reply_to_id, recipient_id: @recipient.id, sender_id: @notification.from_account.id]).zero?
|
!Status.count_by_sql([<<-SQL.squish, id: @notification.target_status.in_reply_to_id, recipient_id: @recipient.id, sender_id: @notification.from_account.id]).zero?
|
||||||
WITH RECURSIVE ancestors(id, in_reply_to_id, replying_to_sender) AS (
|
WITH RECURSIVE ancestors(id, in_reply_to_id, replying_to_sender, path) AS (
|
||||||
SELECT
|
SELECT
|
||||||
s.id, s.in_reply_to_id, (CASE
|
s.id,
|
||||||
|
s.in_reply_to_id,
|
||||||
|
(CASE
|
||||||
WHEN s.account_id = :recipient_id THEN
|
WHEN s.account_id = :recipient_id THEN
|
||||||
EXISTS (
|
EXISTS (
|
||||||
SELECT *
|
SELECT *
|
||||||
@ -84,7 +86,8 @@ class NotifyService < BaseService
|
|||||||
)
|
)
|
||||||
ELSE
|
ELSE
|
||||||
FALSE
|
FALSE
|
||||||
END)
|
END),
|
||||||
|
ARRAY[s.id]
|
||||||
FROM statuses s
|
FROM statuses s
|
||||||
WHERE s.id = :id
|
WHERE s.id = :id
|
||||||
UNION ALL
|
UNION ALL
|
||||||
@ -100,10 +103,11 @@ class NotifyService < BaseService
|
|||||||
)
|
)
|
||||||
ELSE
|
ELSE
|
||||||
FALSE
|
FALSE
|
||||||
END)
|
END),
|
||||||
|
st.path || s.id
|
||||||
FROM ancestors st
|
FROM ancestors st
|
||||||
JOIN statuses s ON s.id = st.in_reply_to_id
|
JOIN statuses s ON s.id = st.in_reply_to_id
|
||||||
WHERE st.replying_to_sender IS FALSE
|
WHERE st.replying_to_sender IS FALSE AND NOT s.id = ANY(path)
|
||||||
)
|
)
|
||||||
SELECT COUNT(*)
|
SELECT COUNT(*)
|
||||||
FROM ancestors st
|
FROM ancestors st
|
||||||
|
Loading…
Reference in New Issue
Block a user