diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-05-11 18:12:42 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-05-11 18:12:42 +0200 |
commit | 45fce0e496727cd1579c630c22592638341f78c6 (patch) | |
tree | ff72ae5b3482e4df7885e1e5a38c982529fd11c4 /app/workers/web | |
parent | 34142ab29c33104793afe3199f102d84b83b9b57 (diff) | |
parent | 352bae8c3ef2aca41de4aacb85d5e036a1d2bace (diff) |
Merge branch 'master' into glitch-soc/merge
Conflicts: app/controllers/invites_controller.rb app/serializers/initial_state_serializer.rb config/locales/ko.yml
Diffstat (limited to 'app/workers/web')
-rw-r--r-- | app/workers/web/push_notification_worker.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/workers/web/push_notification_worker.rb b/app/workers/web/push_notification_worker.rb new file mode 100644 index 000000000..4a40e5c8b --- /dev/null +++ b/app/workers/web/push_notification_worker.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +class Web::PushNotificationWorker + include Sidekiq::Worker + + sidekiq_options backtrace: true + + def perform(subscription_id, notification_id) + subscription = ::Web::PushSubscription.find(subscription_id) + notification = Notification.find(notification_id) + + subscription.push(notification) unless notification.activity.nil? + rescue Webpush::InvalidSubscription, Webpush::ExpiredSubscription + subscription.destroy! + rescue ActiveRecord::RecordNotFound + true + end +end |