accept_notification_request_service.rb 629 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. class AcceptNotificationRequestService < BaseService
  3. include Redisable
  4. def call(request)
  5. NotificationPermission.create!(account: request.account, from_account: request.from_account)
  6. increment_worker_count!(request)
  7. UnfilterNotificationsWorker.perform_async(request.account_id, request.from_account_id)
  8. request.destroy!
  9. end
  10. private
  11. def increment_worker_count!(request)
  12. with_redis do |redis|
  13. redis.incr("notification_unfilter_jobs:#{request.account_id}")
  14. redis.expire("notification_unfilter_jobs:#{request.account_id}", 30.minutes.to_i)
  15. end
  16. end
  17. end