diff options
author | David Yip <yipdw@member.fsf.org> | 2017-10-16 01:29:02 -0500 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2017-10-16 01:29:02 -0500 |
commit | 6cd5b3bbe5a11fcf25bbefba2803f2ae840f39fc (patch) | |
tree | 4bb60f4493fb70cada728a373f74c18b87e8f95d /app/services | |
parent | f72ad67a3967230afd63a9e2d84a2a69331c4787 (diff) | |
parent | 894da3dcca781e27ce9c5130f1021526ac8a6887 (diff) |
Merge remote-tracking branch 'origin/master' into gs-master
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/fetch_link_card_service.rb | 4 | ||||
-rw-r--r-- | app/services/fetch_remote_status_service.rb | 2 | ||||
-rw-r--r-- | app/services/send_interaction_service.rb | 4 | ||||
-rw-r--r-- | app/services/subscribe_service.rb | 3 | ||||
-rw-r--r-- | app/services/unsubscribe_service.rb | 3 |
5 files changed, 11 insertions, 5 deletions
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb index cf3d78683..7029c4d75 100644 --- a/app/services/fetch_link_card_service.rb +++ b/app/services/fetch_link_card_service.rb @@ -72,6 +72,8 @@ class FetchLinkCardService < BaseService def attempt_oembed response = OEmbed::Providers.get(@url) + return false unless response.respond_to?(:type) + @card.type = response.type @card.title = response.respond_to?(:title) ? response.title : '' @card.author_name = response.respond_to?(:author_name) ? response.author_name : '' @@ -113,7 +115,7 @@ class FetchLinkCardService < BaseService detector.strip_tags = true guess = detector.detect(html, response.charset) - page = Nokogiri::HTML(html, nil, guess&.fetch(:encoding)) + page = Nokogiri::HTML(html, nil, guess&.fetch(:encoding, nil)) if meta_property(page, 'twitter:player') @card.type = :video diff --git a/app/services/fetch_remote_status_service.rb b/app/services/fetch_remote_status_service.rb index cacf6ba51..9c009335b 100644 --- a/app/services/fetch_remote_status_service.rb +++ b/app/services/fetch_remote_status_service.rb @@ -40,6 +40,6 @@ class FetchRemoteStatusService < BaseService end def confirmed_domain?(domain, account) - account.domain.nil? || domain.casecmp(account.domain).zero? || domain.casecmp(Addressable::URI.parse(account.remote_url).normalized_host).zero? + account.domain.nil? || domain.casecmp(account.domain).zero? || domain.casecmp(Addressable::URI.parse(account.remote_url || account.uri).normalized_host).zero? end end 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 |