about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorabcang <abcang1015@gmail.com>2017-10-14 21:38:57 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-10-14 14:38:57 +0200
commit2eab41cd1a38fd382a735f32c6ecba7ec193f6f2 (patch)
treed48bce55d3f908ab17848e4f7e415ae9d98982e4 /app/services
parentc6f76db2e16decc1bc1483e616933f561d627c36 (diff)
Close connection when succeeded posting (#5390)
* Close connection when succeeded posting

* Update webmock
Diffstat (limited to 'app/services')
-rw-r--r--app/services/send_interaction_service.rb4
-rw-r--r--app/services/subscribe_service.rb3
-rw-r--r--app/services/unsubscribe_service.rb3
3 files changed, 7 insertions, 3 deletions
diff --git a/app/services/send_interaction_service.rb b/app/services/send_interaction_service.rb
index af205c9c9..fabba8a3e 100644
--- a/app/services/send_interaction_service.rb
+++ b/app/services/send_interaction_service.rb
@@ -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
diff --git a/app/services/subscribe_service.rb b/app/services/subscribe_service.rb
index 2d8af0203..2f725e2ec 100644
--- a/app/services/subscribe_service.rb
+++ b/app/services/subscribe_service.rb
@@ -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
diff --git a/app/services/unsubscribe_service.rb b/app/services/unsubscribe_service.rb
index d84a5a530..01f5c6b7a 100644
--- a/app/services/unsubscribe_service.rb
+++ b/app/services/unsubscribe_service.rb
@@ -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