Select correct self link when parsing Webfinger response (#31110)
This commit is contained in:
parent
a8330be93e
commit
cd0ca4b994
10 changed files with 73 additions and 26 deletions
|
@ -49,7 +49,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
|||
confirmed_username, confirmed_domain = split_acct(webfinger.subject)
|
||||
|
||||
if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero?
|
||||
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
||||
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.self_link_href != @uri
|
||||
|
||||
return
|
||||
end
|
||||
|
@ -58,8 +58,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
|
|||
@username, @domain = split_acct(webfinger.subject)
|
||||
|
||||
raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{@uri} (stopped at #{@username}@#{@domain})" unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
|
||||
|
||||
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.link('self', 'href') != @uri
|
||||
raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.self_link_href != @uri
|
||||
rescue Webfinger::RedirectError => e
|
||||
raise Error, e.message
|
||||
rescue Webfinger::Error => e
|
||||
|
|
|
@ -106,8 +106,6 @@ class ResolveAccountService < BaseService
|
|||
end
|
||||
|
||||
def fetch_account!
|
||||
return unless activitypub_ready?
|
||||
|
||||
with_redis_lock("resolve:#{@username}@#{@domain}") do
|
||||
@account = ActivityPub::FetchRemoteAccountService.new.call(actor_url, suppress_errors: @options[:suppress_errors])
|
||||
end
|
||||
|
@ -122,12 +120,8 @@ class ResolveAccountService < BaseService
|
|||
@options[:skip_cache] || @account.nil? || @account.possibly_stale?
|
||||
end
|
||||
|
||||
def activitypub_ready?
|
||||
['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(@webfinger.link('self', 'type'))
|
||||
end
|
||||
|
||||
def actor_url
|
||||
@actor_url ||= @webfinger.link('self', 'href')
|
||||
@actor_url ||= @webfinger.self_link_href
|
||||
end
|
||||
|
||||
def gone_from_origin?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue