mirror of
https://github.com/discourse/discourse.git
synced 2024-12-14 08:53:44 +08:00
FIX: Staged users getting user_linked and user_quoted emails
This fix ensures that if a staged user is linked to or quoted they won't be emailed about it. A staged user could email into a category, and another user could quote them inside of a completely different category and we don't want a staged user to receive an email for this. Bug report: https://meta.discourse.org/t/-/145202/9
This commit is contained in:
parent
45296a8fe9
commit
6b20d52338
|
@ -90,6 +90,7 @@ class NotificationEmailer
|
||||||
user = notification.user
|
user = notification.user
|
||||||
return unless user.active? || user.staged?
|
return unless user.active? || user.staged?
|
||||||
return if SiteSetting.must_approve_users? && !user.approved? && !user.staged?
|
return if SiteSetting.must_approve_users? && !user.approved? && !user.staged?
|
||||||
|
return if user.staged? && (type == :user_linked || type == :user_quoted)
|
||||||
|
|
||||||
return unless EMAILABLE_POST_TYPES.include?(post_type)
|
return unless EMAILABLE_POST_TYPES.include?(post_type)
|
||||||
|
|
||||||
|
|
|
@ -36,17 +36,24 @@ describe NotificationEmailer do
|
||||||
NotificationEmailer.process_notification(notification)
|
NotificationEmailer.process_notification(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enqueues a job if the user is staged" do
|
it "enqueues a job if the user is staged for non-linked and non-quoted types" do
|
||||||
notification.user.staged = true
|
notification.user.staged = true
|
||||||
Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))
|
if type == :user_linked || type == :user_quoted
|
||||||
|
Jobs.expects(:enqueue_in).with(delay, :user_email, has_entry(type: type)).never
|
||||||
|
else
|
||||||
|
Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))
|
||||||
|
end
|
||||||
NotificationEmailer.process_notification(notification)
|
NotificationEmailer.process_notification(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "enqueues a job if the user is staged even if site requires user approval" do
|
it "enqueues a job if the user is staged even if site requires user approval for non-linked and non-quoted typed" do
|
||||||
SiteSetting.must_approve_users = true
|
|
||||||
|
|
||||||
notification.user.staged = true
|
notification.user.staged = true
|
||||||
Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))
|
SiteSetting.must_approve_users = true
|
||||||
|
if type == :user_linked || type == :user_quoted
|
||||||
|
Jobs.expects(:enqueue_in).with(delay, :user_email, has_entry(type: type)).never
|
||||||
|
else
|
||||||
|
Jobs.expects(:enqueue_in).with(delay, :user_email, NotificationEmailer::EmailUser.notification_params(notification, type))
|
||||||
|
end
|
||||||
NotificationEmailer.process_notification(notification)
|
NotificationEmailer.process_notification(notification)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user