FIX: do not send mailing list emails to unapproved users

This commit is contained in:
Sam 2017-12-13 15:13:17 +11:00
parent a393d3bcbb
commit b998efdc94
2 changed files with 12 additions and 0 deletions

View File

@ -34,6 +34,10 @@ 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.must_approve_users
users = users.where(approved: true)
end
DiscourseEvent.trigger(:notify_mailing_list_subscribers, users, post)
users.find_each do |user|
if Guardian.new(user).can_see?(post)

View File

@ -38,6 +38,14 @@ describe Jobs::NotifyMailingListSubscribers do
context "when mailing list mode is globally enabled" do
before { SiteSetting.disable_mailing_list_mode = false }
context "when site requires approval and user is not approved" do
before do
SiteSetting.login_required = true
SiteSetting.must_approve_users = true
end
include_examples "no emails"
end
context "with an invalid post_id" do
before { post.update(deleted_at: Time.now) }
include_examples "no emails"