mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
b4fb766b23
- POST /api/v1/push/subscription - PUT /api/v1/push/subscription - DELETE /api/v1/push/subscription - New OAuth scope: "push" (required for the above methods)
19 lines
516 B
Ruby
19 lines
516 B
Ruby
# 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
|