revert non queuing of emails
This commit is contained in:
parent
a418a7c5e6
commit
83d8bcdc27
|
@ -55,13 +55,7 @@ class UserEmailObserver < ActiveRecord::Observer
|
||||||
end
|
end
|
||||||
|
|
||||||
def delay
|
def delay
|
||||||
mins = SiteSetting.email_time_window_mins.minutes
|
SiteSetting.email_time_window_mins.minutes
|
||||||
if notification.user &&
|
|
||||||
(!notification.user.last_seen_at || notification.user.last_seen_at < mins.ago)
|
|
||||||
0
|
|
||||||
else
|
|
||||||
mins
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ describe UserEmailObserver do
|
||||||
let!(:notification) { Fabricate(:notification, user: user) }
|
let!(:notification) { Fabricate(:notification, user: user) }
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
it "enqueues a job for the email" do
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, type: :user_mentioned, user_id: notification.user_id, notification_id: notification.id)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_mentioned, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ describe UserEmailObserver do
|
||||||
let!(:notification) { Fabricate(:notification, user: user, notification_type: 9) }
|
let!(:notification) { Fabricate(:notification, user: user, notification_type: 9) }
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
it "enqueues a job for the email" do
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, type: :user_posted, user_id: notification.user_id, notification_id: notification.id)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_posted, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ describe UserEmailObserver do
|
||||||
let!(:notification) { Fabricate(:notification, user: user, notification_type: 2) }
|
let!(:notification) { Fabricate(:notification, user: user, notification_type: 2) }
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
it "enqueues a job for the email" do
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, type: :user_replied, user_id: notification.user_id, notification_id: notification.id)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_replied, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ describe UserEmailObserver do
|
||||||
let!(:notification) { Fabricate(:notification, user: user, notification_type: 3) }
|
let!(:notification) { Fabricate(:notification, user: user, notification_type: 3) }
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
it "enqueues a job for the email" do
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, type: :user_quoted, user_id: notification.user_id, notification_id: notification.id)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_quoted, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
it "doesn't enqueue an email if the user has mention emails disabled" do
|
||||||
user.expects(:email_direct?).returns(false)
|
user.expects(:email_direct?).returns(false)
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, has_entry(type: :user_quoted)).never
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_quoted)).never
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,13 +86,13 @@ describe UserEmailObserver do
|
||||||
let!(:notification) { Fabricate(:notification, user: user, notification_type: 7) }
|
let!(:notification) { Fabricate(:notification, user: user, notification_type: 7) }
|
||||||
|
|
||||||
it "enqueues a job for the email" do
|
it "enqueues a job for the email" do
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, type: :user_invited_to_private_message, user_id: notification.user_id, notification_id: notification.id)
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, type: :user_invited_to_private_message, user_id: notification.user_id, notification_id: notification.id)
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't enqueue an email if the user has mention emails disabled" do
|
it "doesn't enqueue an email if the user has mention emails disabled" do
|
||||||
user.expects(:email_direct?).returns(false)
|
user.expects(:email_direct?).returns(false)
|
||||||
Jobs.expects(:enqueue_in).with(0, :user_email, has_entry(type: :user_invited_to_private_message)).never
|
Jobs.expects(:enqueue_in).with(SiteSetting.email_time_window_mins.minutes, :user_email, has_entry(type: :user_invited_to_private_message)).never
|
||||||
UserEmailObserver.send(:new).after_commit(notification)
|
UserEmailObserver.send(:new).after_commit(notification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue