discourse/app/jobs/regular/send_push_notification.rb
Mark VanLandingham 5eaa876898
DEV: Add bypass_time_window arg to SendPushNotification job (#33293)
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.
2025-06-24 09:43:54 -05:00

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