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)
end
def expected_type?
- @json['type'] == 'Person'
+ SUPPORTED_TYPES.include?(@json['type'])
end
end
end
def person?
- @json['type'] == 'Person'
+ ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(@json['type'])
end
def public_key?
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
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]
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
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)