闭社主体 forked from https://github.com/tootsuite/mastodon
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
591 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.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