unsubscribe_service.rb 591 B

123456789101112131415161718
  1. # frozen_string_literal: true
  2. class UnsubscribeService < BaseService
  3. def call(account)
  4. subscription = account.subscription(api_subscription_url(account.id))
  5. response = subscription.unsubscribe
  6. unless response.successful?
  7. Rails.logger.debug "PuSH unsubscribe for #{account.acct} failed: #{response.message}"
  8. end
  9. account.secret = ''
  10. account.subscription_expires_at = nil
  11. account.save!
  12. rescue HTTP::Error, OpenSSL::SSL::SSLError
  13. Rails.logger.debug "PuSH subscription request for #{account.acct} could not be made due to HTTP or SSL error"
  14. end
  15. end