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