mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 23:56:43 +08:00
FIX: when sending private message emails do not check email_direct setting
This commit is contained in:
parent
ccaf525e8d
commit
0393aa63d4
|
@ -41,7 +41,6 @@ class UserEmailObserver < ActiveRecord::Observer
|
|||
def enqueue(type)
|
||||
return unless notification.user.email_direct?
|
||||
|
||||
|
||||
Jobs.enqueue_in(delay,
|
||||
:user_email,
|
||||
type: type,
|
||||
|
@ -50,7 +49,8 @@ class UserEmailObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
def enqueue_private(type)
|
||||
return unless (notification.user.email_direct? && notification.user.email_private_messages?)
|
||||
return unless notification.user.email_private_messages?
|
||||
|
||||
Jobs.enqueue_in(delay,
|
||||
:user_email,
|
||||
type: type,
|
||||
|
|
|
@ -98,6 +98,24 @@ describe UserEmailObserver do
|
|||
|
||||
end
|
||||
|
||||
context 'private_message' do
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
let!(:notification) { Fabricate(:notification, user: user, notification_type: 6) }
|
||||
|
||||
it "enqueues a job for the email" do
|
||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_private_message, user_id: notification.user_id, notification_id: notification.id)
|
||||
UserEmailObserver.send(:new).after_commit(notification)
|
||||
end
|
||||
|
||||
it "doesn't enqueue an email if the user has private message emails disabled" do
|
||||
user.expects(:email_private_messages?).returns(false)
|
||||
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_private_message)).never
|
||||
UserEmailObserver.send(:new).after_commit(notification)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'user_invited_to_topic' do
|
||||
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
|
Loading…
Reference in New Issue
Block a user