The code powering m.abunchtell.com https://m.abunchtell.com
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.
 
 
 
 

21 lines
653 B

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