mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: do not send mailing list emails to unapproved users
This commit is contained in:
parent
a393d3bcbb
commit
b998efdc94
@ -34,6 +34,10 @@ module Jobs
|
|||||||
WHERE cu.category_id = ? AND cu.user_id = users.id AND cu.notification_level = ?
|
WHERE cu.category_id = ? AND cu.user_id = users.id AND cu.notification_level = ?
|
||||||
)', post.topic.category_id, CategoryUser.notification_levels[:muted])
|
)', 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)
|
DiscourseEvent.trigger(:notify_mailing_list_subscribers, users, post)
|
||||||
users.find_each do |user|
|
users.find_each do |user|
|
||||||
if Guardian.new(user).can_see?(post)
|
if Guardian.new(user).can_see?(post)
|
||||||
|
@ -38,6 +38,14 @@ describe Jobs::NotifyMailingListSubscribers do
|
|||||||
context "when mailing list mode is globally enabled" do
|
context "when mailing list mode is globally enabled" do
|
||||||
before { SiteSetting.disable_mailing_list_mode = false }
|
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
|
context "with an invalid post_id" do
|
||||||
before { post.update(deleted_at: Time.now) }
|
before { post.update(deleted_at: Time.now) }
|
||||||
include_examples "no emails"
|
include_examples "no emails"
|
||||||
|
Loading…
Reference in New Issue
Block a user