diff --git a/app/jobs/regular/notify_mailing_list_subscribers.rb b/app/jobs/regular/notify_mailing_list_subscribers.rb index c4dfacfb326..66a86c89ffe 100644 --- a/app/jobs/regular/notify_mailing_list_subscribers.rb +++ b/app/jobs/regular/notify_mailing_list_subscribers.rb @@ -53,6 +53,14 @@ module Jobs WHERE cu.category_id = ? AND cu.user_id = users.id AND cu.notification_level = ? )', post.topic.category_id, CategoryUser.notification_levels[:muted]) + if SiteSetting.tagging_enabled? + users = users.where('NOT EXISTS ( + SELECT 1 + FROM tag_users tu + WHERE tu.tag_id in (:tag_ids) AND tu.user_id = users.id AND tu.notification_level = :muted + )', tag_ids: post.topic.tag_ids, muted: TagUser.notification_levels[:muted]) + end + if SiteSetting.must_approve_users users = users.where(approved: true) end diff --git a/spec/jobs/notify_mailing_list_subscribers_spec.rb b/spec/jobs/notify_mailing_list_subscribers_spec.rb index 5f4fb51dd05..8d2d7133f29 100644 --- a/spec/jobs/notify_mailing_list_subscribers_spec.rb +++ b/spec/jobs/notify_mailing_list_subscribers_spec.rb @@ -7,9 +7,14 @@ describe Jobs::NotifyMailingListSubscribers do fab!(:mailing_list_user) { Fabricate(:user) } before { mailing_list_user.user_option.update(mailing_list_mode: true, mailing_list_mode_frequency: 1) } + before do + SiteSetting.tagging_enabled = true + end + fab!(:tag) { Fabricate(:tag) } + fab!(:topic) { Fabricate(:topic, tags: [tag]) } fab!(:user) { Fabricate(:user) } - fab!(:post) { Fabricate(:post, user: user) } + fab!(:post) { Fabricate(:post, topic: topic, user: user) } shared_examples "no emails" do it "doesn't send any emails" do @@ -127,6 +132,11 @@ describe Jobs::NotifyMailingListSubscribers do include_examples "no emails" end + context "from a muted tag" do + before { TagUser.create(user: mailing_list_user, tag: tag, notification_level: TagUser.notification_levels[:muted]) } + include_examples "no emails" + end + context "max emails per day was reached" do before { SiteSetting.max_emails_per_day_per_user = 2 }