mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-24 04:36:33 +08:00
This PR allows `bypass_time_window` to be passed to the `SendPushNotification` job, to continue sending a PN, even if the user has been active recently.
19 lines
485 B
Ruby
Vendored
19 lines
485 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class SendPushNotification < ::Jobs::Base
|
|
def execute(args)
|
|
user = User.find_by(id: args[:user_id])
|
|
push_window = SiteSetting.push_notification_time_window_mins
|
|
if !user ||
|
|
(
|
|
!args[:bypass_time_window] && push_window > 0 &&
|
|
user.seen_since?(push_window.minutes.ago)
|
|
)
|
|
return
|
|
end
|
|
|
|
PushNotificationPusher.push(user, args[:payload])
|
|
end
|
|
end
|
|
end
|