DEV: Extract mentions.count method (#21116)
This commit is contained in:
parent
e7292e1682
commit
ea5dec82a6
|
@ -31,6 +31,16 @@ module Chat
|
|||
end
|
||||
end
|
||||
|
||||
def count
|
||||
@count ||=
|
||||
begin
|
||||
result = @parsed_direct_mentions.length + @parsed_group_mentions.length
|
||||
result += 1 if @has_global_mention
|
||||
result += 1 if @has_here_mention
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def global_mentions
|
||||
return User.none unless @has_global_mention
|
||||
channel_members.where.not(username_lower: @parsed_direct_mentions)
|
||||
|
|
|
@ -108,12 +108,7 @@ module Chat
|
|||
private
|
||||
|
||||
def list_users_to_notify
|
||||
mentions_count =
|
||||
@mentions.parsed_direct_mentions.length + @mentions.parsed_group_mentions.length
|
||||
mentions_count += 1 if @mentions.has_global_mention
|
||||
mentions_count += 1 if @mentions.has_here_mention
|
||||
|
||||
skip_notifications = mentions_count > SiteSetting.max_mentions_per_chat_message
|
||||
skip_notifications = @mentions.count > SiteSetting.max_mentions_per_chat_message
|
||||
|
||||
{}.tap do |to_notify|
|
||||
# The order of these methods is the precedence
|
||||
|
|
Loading…
Reference in New Issue