diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2017-08-14 11:27:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-14 11:27:25 +0200 |
commit | 26d26644ac217d770ad2b3f6df6966501842f18b (patch) | |
tree | 4c2be56959b65918105200272eb1c6e8aeaed6e4 | |
parent | 3c6503038ecad20f1b8fa0c9ea7e46087c6e3f22 (diff) |
Require "inbox" to be set on actor to be ActivityPub-ready (#4595)
-rw-r--r-- | app/services/resolve_remote_account_service.rb | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/app/services/resolve_remote_account_service.rb b/app/services/resolve_remote_account_service.rb index 220ef043c..7031c98f5 100644 --- a/app/services/resolve_remote_account_service.rb +++ b/app/services/resolve_remote_account_service.rb @@ -79,7 +79,8 @@ class ResolveRemoteAccountService < BaseService def activitypub_ready? !@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 def handle_ostatus @@ -93,11 +94,9 @@ class ResolveRemoteAccountService < BaseService end 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, json) + @account = ActivityPub::ProcessAccountService.new.call(@username, @domain, actor_json) rescue Oj::ParseError nil end @@ -186,6 +185,13 @@ class ResolveRemoteAccountService < BaseService @atom_body = response.to_s 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 return @atom if defined?(@atom) @atom = Nokogiri::XML(atom_body) |