mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Extract mentions.count method (#21116)
This commit is contained in:
parent
e7292e1682
commit
ea5dec82a6
@ -31,6 +31,16 @@ module Chat
|
|||||||
end
|
end
|
||||||
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
|
def global_mentions
|
||||||
return User.none unless @has_global_mention
|
return User.none unless @has_global_mention
|
||||||
channel_members.where.not(username_lower: @parsed_direct_mentions)
|
channel_members.where.not(username_lower: @parsed_direct_mentions)
|
||||||
|
@ -108,12 +108,7 @@ module Chat
|
|||||||
private
|
private
|
||||||
|
|
||||||
def list_users_to_notify
|
def list_users_to_notify
|
||||||
mentions_count =
|
skip_notifications = @mentions.count > SiteSetting.max_mentions_per_chat_message
|
||||||
@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
|
|
||||||
|
|
||||||
{}.tap do |to_notify|
|
{}.tap do |to_notify|
|
||||||
# The order of these methods is the precedence
|
# The order of these methods is the precedence
|
||||||
|
Loading…
Reference in New Issue
Block a user