Temporarily retire invites and unreacheable for group mentions. We don't want to potentially send hundreds of IDs through MB

This commit is contained in:
Roman Rizzi 2022-12-30 15:01:07 -03:00
parent f6494ec4d6
commit fd676a7243
No known key found for this signature in database
GPG Key ID: 64024A71CE7330D3
3 changed files with 6 additions and 57 deletions

View File

@ -37,9 +37,9 @@ module Jobs
)
.merge(User.not_suspended)
if global_mentions.include?("all")
if global_mentions.include?(Chat::ChatNotifier::ALL_KEYWORD)
members = members.where(user_option: { ignore_channel_wide_mention: true })
elsif global_mentions.include?("here")
elsif global_mentions.include?(Chat::ChatNotifier::HERE_KEYWORD)
members = members.where("last_seen_at < ?", 5.minutes.ago)
end

View File

@ -31,9 +31,10 @@ class Chat::ChatNotifier
HERE_MENTIONS = :here_mentions
GLOBAL_MENTIONS = :global_mentions
STATIC_MENTION_TYPES = [DIRECT_MENTIONS, HERE_MENTIONS, GLOBAL_MENTIONS]
HERE_KEYWORD = 'here'
ALL_KEYWORD = 'all'
MENTION_BATCH_SIZE = 250
class << self
def push_notification_tag(type, chat_channel_id)
"#{Discourse.current_hostname}-chat-#{type}-#{chat_channel_id}"
@ -73,8 +74,8 @@ class Chat::ChatNotifier
end
global_mentions = []
global_mentions << "all" if typed_global_mention?
global_mentions << "here" if typed_here_mention?
global_mentions << ALL_KEYWORD if typed_global_mention?
global_mentions << HERE_KEYWORD if typed_here_mention?
notify_watching_users(
mentioned_channel_member_ids,
@ -168,9 +169,6 @@ class Chat::ChatNotifier
classified.each do |group_name, member_ids|
notify_mentioned_users(group_name, member_ids)
end
inaccessible_mentions[:welcome_to_join] = inaccessible_mentions[:welcome_to_join].concat(grouped[:welcome_to_join])
inaccessible_mentions[:unreachable] = inaccessible_mentions[:unreachable].concat(grouped[:unreachable])
end
end

View File

@ -335,31 +335,6 @@ describe Chat::ChatNotifier do
unreachable_users = unreachable_msg.data[:cannot_see].map { |u| u["id"] }
expect(unreachable_users).to contain_exactly(user_3.id)
end
it "notify posts of users who are part of the mentioned group but participating" do
group =
Fabricate(
:public_group,
users: [user_2, user_3],
mentionable_level: Group::ALIAS_LEVELS[:everyone],
)
msg =
build_cooked_msg("Hello @#{group.name}", user_1, chat_channel: personal_chat_channel)
messages =
MessageBus.track_publish("/chat/#{personal_chat_channel.id}") do
described_class.new(msg, msg.created_at).notify_new
assert_users_were_notifier_with_mention_type(group.name, [user_2.id])
end
unreachable_msg = messages.first
expect(unreachable_msg).to be_present
expect(unreachable_msg.data[:without_membership]).to be_empty
unreachable_users = unreachable_msg.data[:cannot_see].map { |u| u["id"] }
expect(unreachable_users).to contain_exactly(user_3.id)
end
end
end
@ -438,30 +413,6 @@ describe Chat::ChatNotifier do
expect(not_participating_users).to contain_exactly(user_3.id)
end
it "can invite other group members to channel" do
group =
Fabricate(
:public_group,
users: [user_2, user_3],
mentionable_level: Group::ALIAS_LEVELS[:everyone],
)
msg = build_cooked_msg("Hello @#{group.name}", user_1)
messages =
MessageBus.track_publish("/chat/#{channel.id}") do
described_class.new(msg, msg.created_at).notify_new
assert_users_were_notifier_with_mention_type(:direct_mentions, [])
end
not_participating_msg = messages.first
expect(not_participating_msg).to be_present
expect(not_participating_msg.data[:cannot_see]).to be_empty
not_participating_users = not_participating_msg.data[:without_membership].map { |u| u["id"] }
expect(not_participating_users).to contain_exactly(user_3.id)
end
it "cannot invite a member of a group who is ignoring the user who created the message" do
group =
Fabricate(