From 07f1d90b887f25e448e60ba389a06947aa1f9f7d Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 5 Mar 2018 13:49:11 +0800 Subject: [PATCH] FIX: Inviting a group that I am part of creates a notification. https://meta.discourse.org/t/inviting-a-group-to-a-message-does-not-trigger-a-notification-mail/50509/10?u=tgxworld --- app/models/topic.rb | 3 ++- spec/models/topic_spec.rb | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/topic.rb b/app/models/topic.rb index 6e9aef04456..09de70dcfd9 100644 --- a/app/models/topic.rb +++ b/app/models/topic.rb @@ -765,7 +765,8 @@ SQL group_id = group.id group.users.where( - "group_users.notification_level > ?", NotificationLevels.all[:muted] + "group_users.notification_level > ? AND user_id != ?", + NotificationLevels.all[:muted], user.id ).find_each do |u| u.notifications.create!( diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index 2952a9d9210..559013b1526 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -675,6 +675,7 @@ describe Topic do group.add(user) group.add(user_2) + group.add(topic.user) group.group_users.find_by(user: user_2).update!( notification_level: NotificationLevels.all[:muted]