mirror of
https://git.bsd.gay/fef/nyastodon.git
synced 2024-12-25 06:13:43 +01:00
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
|
@ -193,7 +193,7 @@ GEM
|
||||||
railties (>= 4.0.1)
|
railties (>= 4.0.1)
|
||||||
hamster (3.0.0)
|
hamster (3.0.0)
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
hashdiff (0.3.6)
|
hashdiff (0.3.7)
|
||||||
highline (1.7.8)
|
highline (1.7.8)
|
||||||
hiredis (0.6.1)
|
hiredis (0.6.1)
|
||||||
hkdf (0.3.0)
|
hkdf (0.3.0)
|
||||||
|
@ -513,7 +513,7 @@ GEM
|
||||||
uniform_notifier (1.10.0)
|
uniform_notifier (1.10.0)
|
||||||
warden (1.2.7)
|
warden (1.2.7)
|
||||||
rack (>= 1.0)
|
rack (>= 1.0)
|
||||||
webmock (3.0.1)
|
webmock (3.1.0)
|
||||||
addressable (>= 2.3.6)
|
addressable (>= 2.3.6)
|
||||||
crack (>= 0.3.2)
|
crack (>= 0.3.2)
|
||||||
hashdiff
|
hashdiff
|
||||||
|
|
|
@ -12,9 +12,11 @@ class SendInteractionService < BaseService
|
||||||
|
|
||||||
return if !target_account.ostatus? || block_notification?
|
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
|
raise Mastodon::UnexpectedResponseError, delivery unless delivery.code > 199 && delivery.code < 300
|
||||||
|
|
||||||
|
delivery.connection&.close
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -6,7 +6,7 @@ class SubscribeService < BaseService
|
||||||
|
|
||||||
@account = account
|
@account = account
|
||||||
@account.secret = SecureRandom.hex
|
@account.secret = SecureRandom.hex
|
||||||
@response = build_request.perform.flush
|
@response = build_request.perform
|
||||||
|
|
||||||
if response_failed_permanently?
|
if response_failed_permanently?
|
||||||
# We're not allowed to subscribe. Fail and move on.
|
# 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!
|
# We need to retry at a later time. Fail loudly!
|
||||||
raise Mastodon::UnexpectedResponseError, @response
|
raise Mastodon::UnexpectedResponseError, @response
|
||||||
end
|
end
|
||||||
|
@response.connection&.close
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -7,9 +7,10 @@ class UnsubscribeService < BaseService
|
||||||
@account = account
|
@account = account
|
||||||
|
|
||||||
begin
|
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?
|
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
|
rescue HTTP::Error, OpenSSL::SSL::SSLError => e
|
||||||
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{e}"
|
Rails.logger.debug "PuSH unsubscribe for #{@account.acct} failed: #{e}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,6 +16,7 @@ class ActivityPub::DeliveryWorker
|
||||||
|
|
||||||
raise Mastodon::UnexpectedResponseError, @response unless response_successful?
|
raise Mastodon::UnexpectedResponseError, @response unless response_successful?
|
||||||
|
|
||||||
|
@response.connection&.close
|
||||||
failure_tracker.track_success!
|
failure_tracker.track_success!
|
||||||
rescue => e
|
rescue => e
|
||||||
failure_tracker.track_failure!
|
failure_tracker.track_failure!
|
||||||
|
@ -31,7 +32,7 @@ class ActivityPub::DeliveryWorker
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform_request
|
def perform_request
|
||||||
@response = build_request.perform.flush
|
@response = build_request.perform
|
||||||
end
|
end
|
||||||
|
|
||||||
def response_successful?
|
def response_successful?
|
||||||
|
|
|
@ -27,6 +27,7 @@ class Pubsubhubbub::DeliveryWorker
|
||||||
|
|
||||||
raise Mastodon::UnexpectedResponseError, payload_delivery unless response_successful?
|
raise Mastodon::UnexpectedResponseError, payload_delivery unless response_successful?
|
||||||
|
|
||||||
|
payload_delivery.connection&.close
|
||||||
subscription.touch(:last_successful_delivery_at)
|
subscription.touch(:last_successful_delivery_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ class Pubsubhubbub::DeliveryWorker
|
||||||
def callback_post_payload
|
def callback_post_payload
|
||||||
request = Request.new(:post, subscription.callback_url, body: payload)
|
request = Request.new(:post, subscription.callback_url, body: payload)
|
||||||
request.add_headers(headers)
|
request.add_headers(headers)
|
||||||
request.perform.flush
|
request.perform
|
||||||
end
|
end
|
||||||
|
|
||||||
def blocked_domain?
|
def blocked_domain?
|
||||||
|
|
Loading…
Reference in a new issue