2024-03-07 23:53:37 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class AcceptNotificationRequestService < BaseService
|
2024-08-20 00:59:06 +09:00
|
|
|
include Redisable
|
|
|
|
|
2024-03-07 23:53:37 +09:00
|
|
|
def call(request)
|
|
|
|
NotificationPermission.create!(account: request.account, from_account: request.from_account)
|
2024-08-20 00:59:06 +09:00
|
|
|
increment_worker_count!(request)
|
2024-08-14 16:34:30 +09:00
|
|
|
UnfilterNotificationsWorker.perform_async(request.account_id, request.from_account_id)
|
|
|
|
request.destroy!
|
2024-03-07 23:53:37 +09:00
|
|
|
end
|
2024-08-20 00:59:06 +09: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 23:53:37 +09:00
|
|
|
end
|