mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
DEV: Modifier for Chat::Mailer to skip summary email for users (#26011)
This commit is contained in:
parent
f7d7092a7a
commit
04b0f40db8
@ -6,6 +6,11 @@ module Chat
|
|||||||
return unless SiteSetting.chat_enabled
|
return unless SiteSetting.chat_enabled
|
||||||
|
|
||||||
users_with_unprocessed_unread_mentions.find_each do |user|
|
users_with_unprocessed_unread_mentions.find_each do |user|
|
||||||
|
# Apply modifier to `true` -- this allows other plugins to block the chat summary email send
|
||||||
|
if !DiscoursePluginRegistry.apply_modifier(:chat_mailer_send_summary_to_user, true, user)
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
# user#memberships_with_unread_messages is a nested array that looks like [[membership_id, unread_message_id]]
|
# user#memberships_with_unread_messages is a nested array that looks like [[membership_id, unread_message_id]]
|
||||||
# Find the max unread id per membership.
|
# Find the max unread id per membership.
|
||||||
membership_and_max_unread_mention_ids =
|
membership_and_max_unread_mention_ids =
|
||||||
|
@ -235,6 +235,26 @@ describe Chat::Mailer do
|
|||||||
assert_only_queued_once
|
assert_only_queued_once
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with chat_mailer_send_summary_to_user modifier" do
|
||||||
|
let(:modifier_block) { Proc.new { |_| false } }
|
||||||
|
it "skips when modifier evaluates to false" do
|
||||||
|
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
|
||||||
|
|
||||||
|
plugin_instance = Plugin::Instance.new
|
||||||
|
plugin_instance.register_modifier(:chat_mailer_send_summary_to_user, &modifier_block)
|
||||||
|
|
||||||
|
described_class.send_unread_mentions_summary
|
||||||
|
|
||||||
|
assert_summary_skipped
|
||||||
|
ensure
|
||||||
|
DiscoursePluginRegistry.unregister_modifier(
|
||||||
|
plugin_instance,
|
||||||
|
:chat_mailer_send_summary_to_user,
|
||||||
|
&modifier_block
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "update the user membership after we send the email" do
|
describe "update the user membership after we send the email" do
|
||||||
before { Jobs.run_immediately! }
|
before { Jobs.run_immediately! }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user