Merge remote-tracking branch 'origin/master' into gs-master

This commit is contained in:
David Yip
2017-10-16 01:29:02 -05:00
60 changed files with 738 additions and 319 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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