FIX: add a 20 seconds grace period before sending a notification about a PM
This commit is contained in:
parent
c3af4abfb5
commit
ce8c2d34d7
|
@ -29,15 +29,15 @@ class UserEmailObserver < ActiveRecord::Observer
|
|||
end
|
||||
|
||||
def private_message
|
||||
enqueue_private(:user_private_message, 0)
|
||||
enqueue_private(:user_private_message)
|
||||
end
|
||||
|
||||
def invited_to_private_message
|
||||
enqueue(:user_invited_to_private_message, 0)
|
||||
enqueue(:user_invited_to_private_message, private_delay)
|
||||
end
|
||||
|
||||
def invited_to_topic
|
||||
enqueue(:user_invited_to_topic, 0)
|
||||
enqueue(:user_invited_to_topic, private_delay)
|
||||
end
|
||||
|
||||
def self.notification_params(notification, type)
|
||||
|
@ -64,7 +64,7 @@ class UserEmailObserver < ActiveRecord::Observer
|
|||
perform_enqueue(type,delay)
|
||||
end
|
||||
|
||||
def enqueue_private(type, delay=default_delay)
|
||||
def enqueue_private(type, delay=private_delay)
|
||||
return unless notification.user.email_private_messages?
|
||||
perform_enqueue(type,delay)
|
||||
end
|
||||
|
@ -76,11 +76,14 @@ class UserEmailObserver < ActiveRecord::Observer
|
|||
Jobs.enqueue_in(delay, :user_email, self.class.notification_params(notification, type))
|
||||
end
|
||||
|
||||
|
||||
def default_delay
|
||||
SiteSetting.email_time_window_mins.minutes
|
||||
end
|
||||
|
||||
def private_delay
|
||||
20.seconds
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def after_commit(notification)
|
||||
|
|
|
@ -109,7 +109,7 @@ describe UserEmailObserver do
|
|||
|
||||
context 'user_private_message' do
|
||||
let(:type) { :user_private_message }
|
||||
let(:delay) { 0 }
|
||||
let(:delay) { 20.seconds }
|
||||
let!(:notification) { create_notification(6) }
|
||||
|
||||
include_examples "enqueue_private"
|
||||
|
@ -117,7 +117,7 @@ describe UserEmailObserver do
|
|||
|
||||
context 'user_invited_to_private_message' do
|
||||
let(:type) { :user_invited_to_private_message }
|
||||
let(:delay) { 0 }
|
||||
let(:delay) { 20.seconds }
|
||||
let!(:notification) { create_notification(7) }
|
||||
|
||||
include_examples "enqueue_public"
|
||||
|
@ -125,7 +125,7 @@ describe UserEmailObserver do
|
|||
|
||||
context 'user_invited_to_topic' do
|
||||
let(:type) { :user_invited_to_topic }
|
||||
let(:delay) { 0 }
|
||||
let(:delay) { 20.seconds }
|
||||
let!(:notification) { create_notification(13) }
|
||||
|
||||
include_examples "enqueue_public"
|
||||
|
|
Loading…
Reference in New Issue