From ba7cc9809d7113b1057284fc450df3b49eec7768 Mon Sep 17 00:00:00 2001 From: InfiniteStash <117855276+InfiniteStash@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:37:05 +0100 Subject: [PATCH] Fix notifications of comments on own edits (#900) --- pkg/sqlx/querybuilder_notifications.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/sqlx/querybuilder_notifications.go b/pkg/sqlx/querybuilder_notifications.go index 7c53be96..1a6026ac 100644 --- a/pkg/sqlx/querybuilder_notifications.go +++ b/pkg/sqlx/querybuilder_notifications.go @@ -114,21 +114,27 @@ INSERT INTO notifications FROM edit_comments EC JOIN edits E ON EC.edit_id = E.id JOIN user_notifications N ON E.user_id = N.user_id AND N.type = 'COMMENT_OWN_EDIT' - WHERE EC.id = $1 + WHERE E.user_id != EC.user_id + AND EC.id = $1 UNION SELECT N.user_id, N.type, 2 as ordering FROM edit_comments EC JOIN edits E ON EC.edit_id = E.id JOIN edit_comments EO ON EO.edit_id = E.id JOIN user_notifications N ON EO.user_id = N.user_id AND N.type = 'COMMENT_COMMENTED_EDIT' - WHERE EO.user_id != E.user_id AND EO.user_id != EC.user_id AND EC.id = $1 + WHERE EO.user_id != E.user_id + AND EO.user_id != EC.user_id + AND EC.id = $1 UNION SELECT N.user_id, N.type, 3 as ordering FROM edit_comments EC JOIN edits E ON EC.edit_id = E.id JOIN edit_votes EV ON EV.edit_id = E.id JOIN user_notifications N ON EV.user_id = N.user_id AND N.type = 'COMMENT_VOTED_EDIT' - WHERE EV.vote != 'ABSTAIN' AND EV.user_id != E.user_id AND EV.user_id != EC.user_id AND EC.id = $1 + WHERE EV.vote != 'ABSTAIN' + AND EV.user_id != E.user_id + AND EV.user_id != EC.user_id + AND EC.id = $1 ) notifications ORDER BY user_id, ordering ASC `