mirror of
https://github.com/discourse/discourse.git
synced 2025-03-09 14:34:35 +00:00
FIX: PM email to suspended member was broken
This commit is contained in:
parent
a1aeedde53
commit
7a1ff59822
@ -74,7 +74,7 @@ module Jobs
|
|||||||
set_skip_context(type, user.id, to_address || user.email, post.try(:id))
|
set_skip_context(type, user.id, to_address || user.email, post.try(:id))
|
||||||
|
|
||||||
return skip_message(I18n.t("email_log.anonymous_user")) if user.anonymous?
|
return skip_message(I18n.t("email_log.anonymous_user")) if user.anonymous?
|
||||||
return skip_message(I18n.t("email_log.suspended_not_pm")) if user.suspended? && type != :user_private_message
|
return skip_message(I18n.t("email_log.suspended_not_pm")) if user.suspended? && type.to_s != "user_private_message"
|
||||||
|
|
||||||
return if user.staged && type == :digest
|
return if user.staged && type == :digest
|
||||||
|
|
||||||
|
@ -110,21 +110,21 @@ describe Jobs::UserEmail do
|
|||||||
let(:post) { Fabricate(:post, user: user) }
|
let(:post) { Fabricate(:post, user: user) }
|
||||||
|
|
||||||
it 'passes a post as an argument when a post_id is present' do
|
it 'passes a post as an argument when a post_id is present' do
|
||||||
UserNotifications.expects(:private_message).with(user, {post: post}).returns(mailer)
|
UserNotifications.expects(:user_private_message).with(user, {post: post}).returns(mailer)
|
||||||
Email::Sender.any_instance.expects(:send)
|
Email::Sender.any_instance.expects(:send)
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: user.id, post_id: post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't send the email if you've seen the post" do
|
it "doesn't send the email if you've seen the post" do
|
||||||
Email::Sender.any_instance.expects(:send).never
|
Email::Sender.any_instance.expects(:send).never
|
||||||
PostTiming.record_timing(topic_id: post.topic_id, user_id: user.id, post_number: post.post_number, msecs: 6666)
|
PostTiming.record_timing(topic_id: post.topic_id, user_id: user.id, post_number: post.post_number, msecs: 6666)
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: user.id, post_id: post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't send the email if the user deleted the post" do
|
it "doesn't send the email if the user deleted the post" do
|
||||||
Email::Sender.any_instance.expects(:send).never
|
Email::Sender.any_instance.expects(:send).never
|
||||||
post.update_column(:user_deleted, true)
|
post.update_column(:user_deleted, true)
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: user.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_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
|
it "doesn't send the email if user of the post has been deleted" do
|
||||||
@ -136,14 +136,14 @@ describe Jobs::UserEmail do
|
|||||||
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
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: suspended.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: suspended.id, post_id: post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't send email for a pm from a staff user" do
|
it "does send an email for a pm from a staff user" do
|
||||||
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
||||||
pm_from_staff.topic.topic_allowed_users.create!(user_id: suspended.id)
|
pm_from_staff.topic.topic_allowed_users.create!(user_id: suspended.id)
|
||||||
Email::Sender.any_instance.expects(:send).never
|
Email::Sender.any_instance.expects(:send)
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: suspended.id, post_id: pm_from_staff.id)
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: suspended.id, post_id: pm_from_staff.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -152,14 +152,14 @@ describe Jobs::UserEmail 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
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: anonymous.id, post_id: post.id)
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: anonymous.id, post_id: post.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't send email for a pm from a staff user" do
|
it "doesn't send email for a pm from a staff user" do
|
||||||
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
pm_from_staff = Fabricate(:post, user: Fabricate(:moderator))
|
||||||
pm_from_staff.topic.topic_allowed_users.create!(user_id: anonymous.id)
|
pm_from_staff.topic.topic_allowed_users.create!(user_id: anonymous.id)
|
||||||
Email::Sender.any_instance.expects(:send).never
|
Email::Sender.any_instance.expects(:send).never
|
||||||
Jobs::UserEmail.new.execute(type: :private_message, user_id: anonymous.id, post_id: pm_from_staff.id)
|
Jobs::UserEmail.new.execute(type: :user_private_message, user_id: anonymous.id, post_id: pm_from_staff.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user