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
|
end
|
||||||
|
|
||||||
def private_message
|
def private_message
|
||||||
enqueue_private(:user_private_message, 0)
|
enqueue_private(:user_private_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
def invited_to_private_message
|
def invited_to_private_message
|
||||||
enqueue(:user_invited_to_private_message, 0)
|
enqueue(:user_invited_to_private_message, private_delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
def invited_to_topic
|
def invited_to_topic
|
||||||
enqueue(:user_invited_to_topic, 0)
|
enqueue(:user_invited_to_topic, private_delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.notification_params(notification, type)
|
def self.notification_params(notification, type)
|
||||||
|
@ -64,7 +64,7 @@ class UserEmailObserver < ActiveRecord::Observer
|
||||||
perform_enqueue(type,delay)
|
perform_enqueue(type,delay)
|
||||||
end
|
end
|
||||||
|
|
||||||
def enqueue_private(type, delay=default_delay)
|
def enqueue_private(type, delay=private_delay)
|
||||||
return unless notification.user.email_private_messages?
|
return unless notification.user.email_private_messages?
|
||||||
perform_enqueue(type,delay)
|
perform_enqueue(type,delay)
|
||||||
end
|
end
|
||||||
|
@ -76,11 +76,14 @@ class UserEmailObserver < ActiveRecord::Observer
|
||||||
Jobs.enqueue_in(delay, :user_email, self.class.notification_params(notification, type))
|
Jobs.enqueue_in(delay, :user_email, self.class.notification_params(notification, type))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def default_delay
|
def default_delay
|
||||||
SiteSetting.email_time_window_mins.minutes
|
SiteSetting.email_time_window_mins.minutes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def private_delay
|
||||||
|
20.seconds
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def after_commit(notification)
|
def after_commit(notification)
|
||||||
|
|
|
@ -109,7 +109,7 @@ describe UserEmailObserver do
|
||||||
|
|
||||||
context 'user_private_message' do
|
context 'user_private_message' do
|
||||||
let(:type) { :user_private_message }
|
let(:type) { :user_private_message }
|
||||||
let(:delay) { 0 }
|
let(:delay) { 20.seconds }
|
||||||
let!(:notification) { create_notification(6) }
|
let!(:notification) { create_notification(6) }
|
||||||
|
|
||||||
include_examples "enqueue_private"
|
include_examples "enqueue_private"
|
||||||
|
@ -117,7 +117,7 @@ describe UserEmailObserver do
|
||||||
|
|
||||||
context 'user_invited_to_private_message' do
|
context 'user_invited_to_private_message' do
|
||||||
let(:type) { :user_invited_to_private_message }
|
let(:type) { :user_invited_to_private_message }
|
||||||
let(:delay) { 0 }
|
let(:delay) { 20.seconds }
|
||||||
let!(:notification) { create_notification(7) }
|
let!(:notification) { create_notification(7) }
|
||||||
|
|
||||||
include_examples "enqueue_public"
|
include_examples "enqueue_public"
|
||||||
|
@ -125,7 +125,7 @@ describe UserEmailObserver do
|
||||||
|
|
||||||
context 'user_invited_to_topic' do
|
context 'user_invited_to_topic' do
|
||||||
let(:type) { :user_invited_to_topic }
|
let(:type) { :user_invited_to_topic }
|
||||||
let(:delay) { 0 }
|
let(:delay) { 20.seconds }
|
||||||
let!(:notification) { create_notification(13) }
|
let!(:notification) { create_notification(13) }
|
||||||
|
|
||||||
include_examples "enqueue_public"
|
include_examples "enqueue_public"
|
||||||
|
|
Loading…
Reference in New Issue