do not notify staged users about posts withing mailinglist mirror category
This commit is contained in:
parent
1a3ab7c02e
commit
d47fa6653b
|
@ -298,6 +298,8 @@ class PostAlerter
|
||||||
# Make sure the user can see the post
|
# Make sure the user can see the post
|
||||||
return unless Guardian.new(user).can_see?(post)
|
return unless Guardian.new(user).can_see?(post)
|
||||||
|
|
||||||
|
return if user.staged? && post.topic.category&.mailinglist_mirror?
|
||||||
|
|
||||||
notifier_id = opts[:user_id] || post.user_id # xxxxx look at revision history
|
notifier_id = opts[:user_id] || post.user_id # xxxxx look at revision history
|
||||||
|
|
||||||
# apply muting here
|
# apply muting here
|
||||||
|
|
|
@ -627,6 +627,21 @@ describe PostAlerter do
|
||||||
expect(dave.notifications.count).to eq(1)
|
expect(dave.notifications.count).to eq(1)
|
||||||
expect(erin.notifications.count).to eq(1)
|
expect(erin.notifications.count).to eq(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "does not send email notifications to staged users when notification originates in mailinglist mirror category" do
|
||||||
|
category = Fabricate(:mailinglist_mirror_category)
|
||||||
|
topic = Fabricate(:topic, category: category)
|
||||||
|
user = Fabricate(:staged)
|
||||||
|
post = Fabricate(:post, user: user, topic: topic)
|
||||||
|
reply = Fabricate(:post, topic: topic, reply_to_post_number: 1)
|
||||||
|
|
||||||
|
NotificationEmailer.expects(:process_notification).never
|
||||||
|
expect { PostAlerter.post_created(reply) }.to change(user.notifications, :count).by(0)
|
||||||
|
|
||||||
|
category.mailinglist_mirror = false
|
||||||
|
NotificationEmailer.expects(:process_notification).once
|
||||||
|
expect { PostAlerter.post_created(reply) }.to change(user.notifications, :count).by(1)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "watching" do
|
context "watching" do
|
||||||
|
|
Loading…
Reference in New Issue