mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 06:49:14 +08:00
FIX: Do not send system emails to suspended users (#10192)
This commit is contained in:
parent
90512d723c
commit
67582e7d27
|
@ -220,7 +220,7 @@ module Jobs
|
|||
return SkippedEmailLog.reason_types[:user_email_post_deleted]
|
||||
end
|
||||
|
||||
if user.suspended? && !post.user&.staff?
|
||||
if user.suspended? && (!post.user&.staff? || !post.user&.human?)
|
||||
return SkippedEmailLog.reason_types[:user_email_user_suspended]
|
||||
end
|
||||
|
||||
|
|
|
@ -326,6 +326,26 @@ describe Jobs::UserEmail do
|
|||
suspended.email
|
||||
)
|
||||
end
|
||||
|
||||
it "doesn't send PM from system user" do
|
||||
pm_from_system = SystemMessage.create(suspended, :unsilenced)
|
||||
|
||||
system_pm_notification = Fabricate(:notification,
|
||||
user: suspended,
|
||||
topic: pm_from_system.topic,
|
||||
post_number: pm_from_system.post_number,
|
||||
data: { original_post_id: pm_from_system.id }.to_json
|
||||
)
|
||||
|
||||
Jobs::UserEmail.new.execute(
|
||||
type: :user_private_message,
|
||||
user_id: suspended.id,
|
||||
post_id: pm_from_system.id,
|
||||
notification_id: system_pm_notification.id
|
||||
)
|
||||
|
||||
expect(ActionMailer::Base.deliveries).to eq([])
|
||||
end
|
||||
end
|
||||
|
||||
context 'user is anonymous' do
|
||||
|
|
Loading…
Reference in New Issue
Block a user