Take the first recognized actor_type. (#7410)

This commit is contained in:
Surinna Curtis 2018-05-08 06:30:04 -05:00 committed by Eugen Rochko
parent b1938d7853
commit 01dfd6dbc8
2 changed files with 10 additions and 1 deletions

View file

@ -71,7 +71,7 @@ class ActivityPub::ProcessAccountService < BaseService
@account.note = @json['summary'] || '' @account.note = @json['summary'] || ''
@account.locked = @json['manuallyApprovesFollowers'] || false @account.locked = @json['manuallyApprovesFollowers'] || false
@account.fields = property_values || {} @account.fields = property_values || {}
@account.actor_type = @json['type'] @account.actor_type = actor_type
end end
def set_fetchable_attributes! def set_fetchable_attributes!
@ -96,6 +96,14 @@ class ActivityPub::ProcessAccountService < BaseService
ActivityPub::SynchronizeFeaturedCollectionWorker.perform_async(@account.id) ActivityPub::SynchronizeFeaturedCollectionWorker.perform_async(@account.id)
end end
def actor_type
if @json['type'].is_a?(Array)
@json['type'].find { |type| ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES.include?(type) }
else
@json['type']
end
end
def image_url(key) def image_url(key)
value = first_of_value(@json[key]) value = first_of_value(@json[key])

View file

@ -116,6 +116,7 @@ RSpec.describe ResolveAccountService, type: :service do
expect(account.activitypub?).to eq true expect(account.activitypub?).to eq true
expect(account.domain).to eq 'ap.example.com' expect(account.domain).to eq 'ap.example.com'
expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox' expect(account.inbox_url).to eq 'https://ap.example.com/users/foo/inbox'
expect(account.actor_type).to eq 'Person'
end end
end end