FIX: do not send emails when channel-wide mentions are disabled in a channel (#20677)
This regressed with the commit fa543cd
. Starting from that commit, we create mention records even if a user shouldn't be notified. So when sending emails, we should be making sure if a notification was actually created for a mention. This is essentially the whole fix that we need here. Tests will be provided in a following PR.
This commit is contained in:
parent
d0c6b33cc2
commit
e6c04e2dc2
|
@ -10,7 +10,9 @@ module Chat::UserNotificationsExtension
|
||||||
.joins(:user, :chat_channel)
|
.joins(:user, :chat_channel)
|
||||||
.where.not(user: user)
|
.where.not(user: user)
|
||||||
.where("chat_messages.created_at > ?", 1.week.ago)
|
.where("chat_messages.created_at > ?", 1.week.ago)
|
||||||
.joins("LEFT OUTER JOIN chat_mentions cm ON cm.chat_message_id = chat_messages.id")
|
.joins(
|
||||||
|
"LEFT OUTER JOIN chat_mentions cm ON cm.chat_message_id = chat_messages.id AND cm.notification_id IS NOT NULL",
|
||||||
|
)
|
||||||
.joins(
|
.joins(
|
||||||
"INNER JOIN user_chat_channel_memberships uccm ON uccm.chat_channel_id = chat_channels.id",
|
"INNER JOIN user_chat_channel_memberships uccm ON uccm.chat_channel_id = chat_channels.id",
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue