@ -23,18 +23,19 @@ class ResolveRemoteAccountService < BaseService
@webfinger = Goldfinger . finger ( " acct: #{ uri } " )
raise Goldfinger :: Error , 'Missing resource links' if links_missing?
confirmed_username , confirmed_domain = @webfinger . subject . gsub ( / \ Aacct: / , '' ) . split ( '@' )
if confirmed_username . casecmp ( @username ) . zero? && confirmed_domain . casecmp ( @domain ) . zero?
@username = confirmed_username
@domain = confirmed_domain
elsif redirected . nil?
return call ( " #{ confirmed_username } @ #{ confirmed_domain } " , update_profile , true )
else
return call ( " #{ confirmed_username } @ #{ confirmed_domain } " , update_profile , true ) if redirected . nil?
r aise Goldfinger :: Error , 'Requested and r eturned acct URIs do not match'
Rails . logger . debug 'Requested and returned acct URIs do not match'
r eturn
end
return if links_missing?
return Account . find_local ( @username ) if TagManager . instance . local_domain? ( @domain )
RedisLock . acquire ( lock_options ) do | lock |
@ -49,6 +50,9 @@ class ResolveRemoteAccountService < BaseService
end
@account
rescue Goldfinger :: Error = > e
Rails . logger . debug " Webfinger query for #{ uri } unsuccessful: #{ e } "
nil
end
private
@ -57,7 +61,9 @@ class ResolveRemoteAccountService < BaseService
@webfinger . link ( 'http://schemas.google.com/g/2010#updates-from' ) . nil? ||
@webfinger . link ( 'salmon' ) . nil? ||
@webfinger . link ( 'http://webfinger.net/rel/profile-page' ) . nil? ||
@webfinger . link ( 'magic-public-key' ) . nil?
@webfinger . link ( 'magic-public-key' ) . nil? ||
canonical_uri . nil? ||
hub_url . nil?
end
def webfinger_update_due?
@ -123,19 +129,14 @@ class ResolveRemoteAccountService < BaseService
author_uri = owner . at_xpath ( './xmlns:uri' ) unless owner . nil?
end
raise Goldfinger :: Error , 'Author URI could not be found' if author_uri . nil?
@canonical_uri = author_uri . content
@canonical_uri = author_uri . nil? ? nil : author_uri . content
end
def hub_url
return @hub_url if defined? ( @hub_url )
hubs = atom . xpath ( '//xmlns:link[@rel="hub"]' )
raise Goldfinger :: Error , 'No PubSubHubbub hubs found' if hubs . empty? || hubs . first [ 'href' ] . nil?
@hub_url = hubs . first [ 'href' ]
@hub_url = hubs . empty? || hubs . first [ 'href' ] . nil? ? nil : hubs . first [ 'href' ]
end
def atom_body
@ -143,7 +144,7 @@ class ResolveRemoteAccountService < BaseService
response = Request . new ( :get , atom_url ) . perform
raise Goldfinger:: Error , " Feed attempt failed for #{ atom_url } : HTTP #{ response . code } " unless response . code == 200
raise Mastodon:: UnexpectedResponseError , response unless response . code == 200
@atom_body = response . to_s
end