mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Do not send email when user of the post has been deleted. (#4228)
This commit is contained in:
parent
e1061acd32
commit
b68860ee28
@ -175,10 +175,11 @@ module Jobs
|
|||||||
# If this email has a related post, don't send an email if it's been deleted or seen recently.
|
# If this email has a related post, don't send an email if it's been deleted or seen recently.
|
||||||
def skip_email_for_post(post, user)
|
def skip_email_for_post(post, user)
|
||||||
if post
|
if post
|
||||||
return I18n.t('email_log.topic_nil') if post.topic.blank?
|
return I18n.t('email_log.topic_nil') if post.topic.blank?
|
||||||
return I18n.t('email_log.post_deleted') if post.user_deleted?
|
return I18n.t('email_log.post_user_deleted') if post.user.blank?
|
||||||
return I18n.t('email_log.user_suspended') if (user.suspended? && !post.user.try(:staff?))
|
return I18n.t('email_log.post_deleted') if post.user_deleted?
|
||||||
return I18n.t('email_log.already_read') if PostTiming.where(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id).present?
|
return I18n.t('email_log.user_suspended') if (user.suspended? && !post.user.try(:staff?))
|
||||||
|
return I18n.t('email_log.already_read') if PostTiming.where(topic_id: post.topic_id, post_number: post.post_number, user_id: user.id).present?
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -2413,6 +2413,7 @@ en:
|
|||||||
spam_hosts: "This new user tried to create multiple posts with links to the same domain (%{domain}). See the <a href='/admin/site_settings/category/spam'>`newuser_spam_host_threshold`</a> site setting."
|
spam_hosts: "This new user tried to create multiple posts with links to the same domain (%{domain}). See the <a href='/admin/site_settings/category/spam'>`newuser_spam_host_threshold`</a> site setting."
|
||||||
|
|
||||||
email_log:
|
email_log:
|
||||||
|
post_user_deleted: "User of the post has been deleted."
|
||||||
no_user: "Can't find user with id %{user_id}"
|
no_user: "Can't find user with id %{user_id}"
|
||||||
anonymous_user: "User is anonymous"
|
anonymous_user: "User is anonymous"
|
||||||
suspended_not_pm: "User is suspended, not a message"
|
suspended_not_pm: "User is suspended, not a message"
|
||||||
|
@ -125,6 +125,12 @@ describe Jobs::UserEmail do
|
|||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't send the email if user of the post has been deleted" do
|
||||||
|
Email::Sender.any_instance.expects(:send).never
|
||||||
|
post.update_attributes!(user_id: nil)
|
||||||
|
Jobs::UserEmail.new.execute(type: :user_replied, user_id: user.id, post_id: post.id)
|
||||||
|
end
|
||||||
|
|
||||||
context 'user is suspended' do
|
context 'user is suspended' do
|
||||||
it "doesn't send email for a pm from a regular user" do
|
it "doesn't send email for a pm from a regular user" do
|
||||||
Email::Sender.any_instance.expects(:send).never
|
Email::Sender.any_instance.expects(:send).never
|
||||||
|
Loading…
Reference in New Issue
Block a user