mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-21 20:15:10 +01:00
Fix errors preventing UnsubscribeService from working (#4866)
This commit is contained in:
parent
6867681c7c
commit
90712d4293
@ -5,15 +5,18 @@ class UnsubscribeService < BaseService
|
|||||||
return if account.hub_url.blank?
|
return if account.hub_url.blank?
|
||||||
|
|
||||||
@account = account
|
@account = account
|
||||||
|
|
||||||
|
begin
|
||||||
@response = build_request.perform
|
@response = build_request.perform
|
||||||
|
|
||||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{@response.status}" unless @response.status.success?
|
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{@response.status}" unless @response.status.success?
|
||||||
|
rescue HTTP::Error, OpenSSL::SSL::SSLError => e
|
||||||
|
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{e}"
|
||||||
|
end
|
||||||
|
|
||||||
@account.secret = ''
|
@account.secret = ''
|
||||||
@account.subscription_expires_at = nil
|
@account.subscription_expires_at = nil
|
||||||
@account.save!
|
@account.save!
|
||||||
rescue HTTP::Error, OpenSSL::SSL::SSLError
|
|
||||||
Rails.logger.debug "PuSH subscription request for #{@account.acct} could not be made due to HTTP or SSL error"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -26,7 +26,7 @@ RSpec.describe UnsubscribeService do
|
|||||||
stub_request(:post, 'http://hub.example.com/').to_raise(HTTP::Error)
|
stub_request(:post, 'http://hub.example.com/').to_raise(HTTP::Error)
|
||||||
subject.call(account)
|
subject.call(account)
|
||||||
|
|
||||||
expect(logger).to have_received(:debug).with(/PuSH subscription request for bob@example.com could not be made due to HTTP or SSL error/)
|
expect(logger).to have_received(:debug).with(/unsubscribe for bob@example.com failed/)
|
||||||
end
|
end
|
||||||
|
|
||||||
def stub_logger
|
def stub_logger
|
||||||
|
Loading…
Reference in New Issue
Block a user