You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
594 B

  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.status.success?
  7. Rails.logger.debug "PuSH unsubscribe for #{account.acct} failed: #{response.status}"
  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