]> cat aescling's git repositories - mastodon.git/commitdiff
Support all ActivityPub actor types (#6997)
authorEugen Rochko <eugen@zeonfederated.com>
Mon, 2 Apr 2018 00:10:53 +0000 (02:10 +0200)
committerGitHub <noreply@github.com>
Mon, 2 Apr 2018 00:10:53 +0000 (02:10 +0200)
Fix #6973

app/services/activitypub/fetch_remote_account_service.rb
app/services/activitypub/fetch_remote_key_service.rb
app/services/fetch_atom_service.rb
app/services/resolve_account_service.rb
app/services/resolve_url_service.rb

index d6ba625a9a467929d83d4049a280900e1372c57b..5024853ca5224458ace9a4ef3c519c25846ff67d 100644 (file)
@@ -3,6 +3,8 @@
 class ActivityPub::FetchRemoteAccountService < BaseService
   include JsonLdHelper
 
+  SUPPORTED_TYPES = %w(Application Group Organization Person Service).freeze
+
   # Should be called when uri has already been checked for locality
   # Does a WebFinger roundtrip on each call
   def call(uri, id: true, prefetched_body: nil)
@@ -54,6 +56,6 @@ class ActivityPub::FetchRemoteAccountService < BaseService
   end
 
   def expected_type?
-    @json['type'] == 'Person'
+    SUPPORTED_TYPES.include?(@json['type'])
   end
 end
index ce1048feebe60a4ff696db4f88b376a61dc1b648..41837d46208a99e635b24c061dae33b53b7c3752 100644 (file)
@@ -43,7 +43,7 @@ class ActivityPub::FetchRemoteKeyService < BaseService
   end
 
   def person?
-    @json['type'] == 'Person'
+    ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(@json['type'])
   end
 
   def public_key?
@@ -55,6 +55,6 @@ class ActivityPub::FetchRemoteKeyService < BaseService
   end
 
   def confirmed_owner?
-    @owner['type'] == 'Person' && value_or_id(@owner['publicKey']) == @json['id']
+    ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(@owner['type']) && value_or_id(@owner['publicKey']) == @json['id']
   end
 end
index 87076cc077111f9ec1085296f154f6aef1e5cf23..0444baf74a2b863632c8be30a34c8b4054f47d0c 100644 (file)
@@ -42,7 +42,7 @@ class FetchAtomService < BaseService
     elsif ['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(response.mime_type)
       body = response.body_with_limit
       json = body_to_json(body)
-      if supported_context?(json) && json['type'] == 'Person' && json['inbox'].present?
+      if supported_context?(json) && ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(json['type']) && json['inbox'].present?
         [json['id'], { prefetched_body: body, id: true }, :activitypub]
       elsif supported_context?(json) && expected_type?(json)
         [json['id'], { prefetched_body: body, id: true }, :activitypub]
index 744ea24f4dbd0ab5565410f6f8a9179e96346898..8cba88f0150e123caad592dee097081b7ebb47cb 100644 (file)
@@ -189,7 +189,7 @@ class ResolveAccountService < BaseService
     return @actor_json if defined?(@actor_json)
 
     json        = fetch_resource(actor_url, false)
-    @actor_json = supported_context?(json) && json['type'] == 'Person' ? json : nil
+    @actor_json = supported_context?(json) && ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(json['type']) ? json : nil
   end
 
   def atom
index 9499dc286e360abd4865693fa4539916caebd74a..c19b568cb0e10e88670ecbc54c15bfff5c225901 100644 (file)
@@ -17,7 +17,7 @@ class ResolveURLService < BaseService
 
   def process_url
     case type
-    when 'Person'
+    when 'Application', 'Group', 'Organization', 'Person', 'Service'
       FetchRemoteAccountService.new.call(atom_url, body, protocol)
     when 'Note', 'Article', 'Image', 'Video'
       FetchRemoteStatusService.new.call(atom_url, body, protocol)