diff options
author | Claire <claire.github-309c@sitedethib.com> | 2022-02-03 14:09:19 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-03 14:09:19 +0100 |
commit | 73b730e649555c9b0d2419130c5496e715fd3387 (patch) | |
tree | a6c11d9cffdcb2f37846a85cd0303919eab822a6 /app/services/notify_service.rb | |
parent | 20a4b8081f419195334faee1b066e7e609ad4ffe (diff) | |
parent | 2beb0a7af59c772f8b92872f9fa0e0c97963b8fb (diff) |
Merge pull request #1676 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/services/notify_service.rb')
-rw-r--r-- | app/services/notify_service.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb index 09e28b76b..0f3516d28 100644 --- a/app/services/notify_service.rb +++ b/app/services/notify_service.rb @@ -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 !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 - s.id, s.in_reply_to_id, (CASE + s.id, + s.in_reply_to_id, + (CASE WHEN s.account_id = :recipient_id THEN EXISTS ( SELECT * @@ -84,7 +86,8 @@ class NotifyService < BaseService ) ELSE FALSE - END) + END), + ARRAY[s.id] FROM statuses s WHERE s.id = :id UNION ALL @@ -100,10 +103,11 @@ class NotifyService < BaseService ) ELSE FALSE - END) + END), + st.path || s.id FROM ancestors st 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(*) FROM ancestors st |