2024-03-07 15:53:37 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AcceptNotificationRequestService < BaseService
|
2024-08-19 17:59:06 +02:00
|
|
|
include Redisable
|
|
|
|
|
2024-03-07 15:53:37 +01:00
|
|
|
def call(request)
|
|
|
|
NotificationPermission.create!(account: request.account, from_account: request.from_account)
|
2024-08-19 17:59:06 +02:00
|
|
|
increment_worker_count!(request)
|
2024-08-14 09:34:30 +02:00
|
|
|
UnfilterNotificationsWorker.perform_async(request.account_id, request.from_account_id)
|
|
|
|
request.destroy!
|
2024-03-07 15:53:37 +01:00
|
|
|
end
|
2024-08-19 17:59:06 +02:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def increment_worker_count!(request)
|
|
|
|
with_redis do |redis|
|
|
|
|
redis.incr("notification_unfilter_jobs:#{request.account_id}")
|
|
|
|
redis.expire("notification_unfilter_jobs:#{request.account_id}", 30.minutes.to_i)
|
|
|
|
end
|
|
|
|
end
|
2024-03-07 15:53:37 +01:00
|
|
|
end
|