Close connection when succeeded posting (#5390)
* Close connection when succeeded posting * Update webmock
This commit is contained in:
parent
c6f76db2e1
commit
2eab41cd1a
6 changed files with 13 additions and 7 deletions
|
@ -12,9 +12,11 @@ class SendInteractionService < BaseService
|
|||
|
||||
return if !target_account.ostatus? || block_notification?
|
||||
|
||||
delivery = build_request.perform.flush
|
||||
delivery = build_request.perform
|
||||
|
||||
raise Mastodon::UnexpectedResponseError, delivery unless delivery.code > 199 && delivery.code < 300
|
||||
|
||||
delivery.connection&.close
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -6,7 +6,7 @@ class SubscribeService < BaseService
|
|||
|
||||
@account = account
|
||||
@account.secret = SecureRandom.hex
|
||||
@response = build_request.perform.flush
|
||||
@response = build_request.perform
|
||||
|
||||
if response_failed_permanently?
|
||||
# We're not allowed to subscribe. Fail and move on.
|
||||
|
@ -20,6 +20,7 @@ class SubscribeService < BaseService
|
|||
# We need to retry at a later time. Fail loudly!
|
||||
raise Mastodon::UnexpectedResponseError, @response
|
||||
end
|
||||
@response.connection&.close
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -7,9 +7,10 @@ class UnsubscribeService < BaseService
|
|||
@account = account
|
||||
|
||||
begin
|
||||
@response = build_request.perform.flush
|
||||
@response = build_request.perform
|
||||
|
||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{@response.status}" unless @response.status.success?
|
||||
@response.connection&.close
|
||||
rescue HTTP::Error, OpenSSL::SSL::SSLError => e
|
||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{e}"
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue