mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
DEV: Create a chat_mention record when self mentioning (#21438)
In the past, we create a `chat_mention` records only when we wanted to notify a user about a mention. Since we don't send notifications when a user mentioning himself, we didn't create a `chat_mention` records in those cases. Now we use `chat_mentions` records in other scenarios too, so when a user is mentioning himself we want to: 1. Create a `chat_mention` record for that mention 2. Do not create a notification for that mention
This commit is contained in:

committed by
GitHub

parent
f494e54128
commit
2703f2311a
@ -132,6 +132,7 @@ module Chat
|
||||
.global_mentions
|
||||
.not_suspended
|
||||
.where(user_options: { ignore_channel_wide_mention: [false, nil] })
|
||||
.where.not(username_lower: @user.username_lower)
|
||||
.where.not(id: already_covered_ids)
|
||||
.pluck(:id)
|
||||
|
||||
@ -150,6 +151,7 @@ module Chat
|
||||
.here_mentions
|
||||
.not_suspended
|
||||
.where(user_options: { ignore_channel_wide_mention: [false, nil] })
|
||||
.where.not(username_lower: @user.username_lower)
|
||||
.where.not(id: already_covered_ids)
|
||||
.pluck(:id)
|
||||
|
||||
@ -187,9 +189,12 @@ module Chat
|
||||
direct_mentions = []
|
||||
else
|
||||
direct_mentions =
|
||||
@chat_message.parsed_mentions.direct_mentions.not_suspended.where.not(
|
||||
id: already_covered_ids,
|
||||
)
|
||||
@chat_message
|
||||
.parsed_mentions
|
||||
.direct_mentions
|
||||
.not_suspended
|
||||
.where.not(username_lower: @user.username_lower)
|
||||
.where.not(id: already_covered_ids)
|
||||
end
|
||||
|
||||
grouped = group_users_to_notify(direct_mentions)
|
||||
@ -209,6 +214,7 @@ module Chat
|
||||
.group_mentions
|
||||
.not_suspended
|
||||
.where("user_count <= ?", SiteSetting.max_users_notified_per_group_mention)
|
||||
.where.not(username_lower: @user.username_lower)
|
||||
.where.not(id: already_covered_ids)
|
||||
|
||||
too_many_members, mentionable =
|
||||
|
@ -91,7 +91,6 @@ module Chat
|
||||
.joins(:user_option)
|
||||
.real
|
||||
.where(user_options: { chat_enabled: true })
|
||||
.where.not(username_lower: @message.user.username.downcase)
|
||||
end
|
||||
|
||||
def parse_mentions(message)
|
||||
|
Reference in New Issue
Block a user