Require "inbox" to be set on actor to be ActivityPub-ready (#4595)

lolsob-rspec
Eugen Rochko 2017-08-14 11:27:25 +02:00 committed by GitHub
parent 0e5c8372e7
commit 5bc37d814f
1 changed files with 11 additions and 5 deletions

View File

@ -79,7 +79,8 @@ class ResolveRemoteAccountService < BaseService
def activitypub_ready? def activitypub_ready?
!@webfinger.link('self').nil? && !@webfinger.link('self').nil? &&
['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(@webfinger.link('self').type) ['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(@webfinger.link('self').type) &&
actor_json['inbox'].present?
end end
def handle_ostatus def handle_ostatus
@ -93,11 +94,9 @@ class ResolveRemoteAccountService < BaseService
end end
def handle_activitypub def handle_activitypub
json = fetch_resource(actor_url) return if actor_json.nil?
return unless supported_context?(json) && json['type'] == 'Person' @account = ActivityPub::ProcessAccountService.new.call(@username, @domain, actor_json)
@account = ActivityPub::ProcessAccountService.new.call(@username, @domain, json)
rescue Oj::ParseError rescue Oj::ParseError
nil nil
end end
@ -186,6 +185,13 @@ class ResolveRemoteAccountService < BaseService
@atom_body = response.to_s @atom_body = response.to_s
end end
def actor_json
return @actor_json if defined?(@actor_json)
json = fetch_resource(actor_url)
@actor_json = supported_context?(json) && json['type'] == 'Person' ? json : nil
end
def atom def atom
return @atom if defined?(@atom) return @atom if defined?(@atom)
@atom = Nokogiri::XML(atom_body) @atom = Nokogiri::XML(atom_body)