mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-21 01:53:41 +08:00
This change is mainly a refactor of the desktop notifications service to improve readability and have standardised values for tracking state for current user in regards to the Notification API and Push API. Also improves readability when handling push notification jobs, especially in scenarios where the push_notification_time_window_mins site setting is set to 0, which will allow sending push notifications instantly.
13 lines
385 B
Ruby
Vendored
13 lines
385 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
|
|
return if !user || (push_window > 0 && user.seen_since?(push_window.minutes.ago))
|
|
|
|
PushNotificationPusher.push(user, args[:payload])
|
|
end
|
|
end
|
|
end
|