1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
This commit is contained in:
Matt Jankowski 2024-07-31 14:09:15 +00:00 committed by GitHub
commit ed5b838d3e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 5 additions and 15 deletions

View file

@ -1,7 +0,0 @@
# frozen_string_literal: true
module WebfingerHelper
def webfinger!(uri)
Webfinger.new(uri).perform
end
end

View file

@ -3,7 +3,6 @@
class RemoteFollow class RemoteFollow
include ActiveModel::Validations include ActiveModel::Validations
include RoutingHelper include RoutingHelper
include WebfingerHelper
attr_accessor :acct, :addressable_template attr_accessor :acct, :addressable_template
@ -66,7 +65,7 @@ class RemoteFollow
end end
def acct_resource def acct_resource
@acct_resource ||= webfinger!("acct:#{acct}") @acct_resource ||= Webfinger.new("acct:#{acct}").perform
rescue Webfinger::Error, HTTP::ConnectionError rescue Webfinger::Error, HTTP::ConnectionError
nil nil
end end

View file

@ -3,7 +3,6 @@
class ActivityPub::FetchRemoteActorService < BaseService class ActivityPub::FetchRemoteActorService < BaseService
include JsonLdHelper include JsonLdHelper
include DomainControlHelper include DomainControlHelper
include WebfingerHelper
class Error < StandardError; end class Error < StandardError; end
@ -45,7 +44,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
private private
def check_webfinger! def check_webfinger!
webfinger = webfinger!("acct:#{@username}@#{@domain}") webfinger = Webfinger.new("acct:#{@username}@#{@domain}").perform
confirmed_username, confirmed_domain = split_acct(webfinger.subject) confirmed_username, confirmed_domain = split_acct(webfinger.subject)
if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero? if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero?
@ -54,7 +53,7 @@ class ActivityPub::FetchRemoteActorService < BaseService
return return
end end
webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}") webfinger = Webfinger.new("acct:#{confirmed_username}@#{confirmed_domain}").perform
@username, @domain = split_acct(webfinger.subject) @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 Webfinger::RedirectError, "Too many webfinger redirects for URI #{@uri} (stopped at #{@username}@#{@domain})" unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?

View file

@ -2,7 +2,6 @@
class ResolveAccountService < BaseService class ResolveAccountService < BaseService
include DomainControlHelper include DomainControlHelper
include WebfingerHelper
include Redisable include Redisable
include Lockable include Lockable
@ -81,7 +80,7 @@ class ResolveAccountService < BaseService
end end
def process_webfinger!(uri) def process_webfinger!(uri)
@webfinger = webfinger!("acct:#{uri}") @webfinger = Webfinger.new("acct:#{uri}").perform
confirmed_username, confirmed_domain = split_acct(@webfinger.subject) confirmed_username, confirmed_domain = split_acct(@webfinger.subject)
if confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero? if confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?
@ -91,7 +90,7 @@ class ResolveAccountService < BaseService
end end
# Account doesn't match, so it may have been redirected # Account doesn't match, so it may have been redirected
@webfinger = webfinger!("acct:#{confirmed_username}@#{confirmed_domain}") @webfinger = Webfinger.new("acct:#{confirmed_username}@#{confirmed_domain}").perform
@username, @domain = split_acct(@webfinger.subject) @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 Webfinger::RedirectError, "Too many webfinger redirects for URI #{uri} (stopped at #{@username}@#{@domain})" unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero?