0
0
Fork 0

Fix some ActivityPub JSON bugs (#4796)

- Fix assumption that `url` is always a string. Handle it if it's an
  array of strings, array of objects, object, or string, both for
  accounts and for objects
- `sharedInbox` is actually supposed to be under `endpoints`, handle
  both cases and adjust the serializer
This commit is contained in:
Eugen Rochko 2017-09-04 18:26:33 +02:00 committed by GitHub
parent 2293466edd
commit 9b50a9dd83
3 changed files with 40 additions and 8 deletions

View file

@ -33,7 +33,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
def status_params
{
uri: @object['id'],
url: @object['url'] || @object['id'],
url: object_url || @object['id'],
account: @account,
text: text_from_content || '',
language: language_from_content,
@ -147,6 +147,16 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
@object['contentMap'].keys.first
end
def object_url
return if @object['url'].blank?
value = first_of_value(@object['url'])
return value if value.is_a?(String)
value['href']
end
def language_map?
@object['contentMap'].is_a?(Hash) && !@object['contentMap'].empty?
end