mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
FIX: when sending private message emails do not check email_direct setting
This commit is contained in:
parent
5da5269652
commit
545f19500d
2 changed files with 20 additions and 2 deletions
|
@ -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 a new issue