FIX: Respect muted tags for mailing list mode
If a user has a tag muted, don't send them emails about that tag. We've done this forever for categories so it makes sense to do it for tags too.
This commit is contained in:
parent
223edd1286
commit
345764565f
|
@ -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
|
||||
|
|
|
@ -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 }
|
||||
|
||||
|
|
Loading…
Reference in New Issue