From d113ccd93cd02b642dbd23c3040ce071a88271af Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 13 Jan 2019 09:38:01 +0000 Subject: [PATCH] Making Friendica compatible to Nextcloud Social --- src/Model/APContact.php | 2 +- src/Protocol/ActivityPub/Receiver.php | 4 ++-- src/Util/JsonLD.php | 4 ++++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index 2b5a5c4e7..3a9f42fdd 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -137,7 +137,7 @@ class APContact extends BaseObject $apcontact['about'] = HTML::toBBCode(JsonLD::fetchElement($compacted, 'as:summary')); $apcontact['photo'] = JsonLD::fetchElement($compacted, 'as:icon', '@id'); - if (is_array($apcontact['photo'])) { + if (is_array($apcontact['photo']) || !empty($compacted['as:icon']['as:url']['@id'])) { $apcontact['photo'] = JsonLD::fetchElement($compacted['as:icon'], 'as:url', '@id'); } diff --git a/src/Protocol/ActivityPub/Receiver.php b/src/Protocol/ActivityPub/Receiver.php index 5459bca34..ac75155b2 100644 --- a/src/Protocol/ActivityPub/Receiver.php +++ b/src/Protocol/ActivityPub/Receiver.php @@ -826,10 +826,10 @@ class Receiver $object_data = []; $object_data['object_type'] = JsonLD::fetchElement($object, '@type'); $object_data['id'] = JsonLD::fetchElement($object, '@id'); - $object_data['reply-to-id'] = JsonLD::fetchElement($object, 'as:inReplyTo'); - if (empty($object_data['reply-to-id'])) { + // An empty "id" field is translated to "./" by the compactor, so we have to check for this content + if (empty($object_data['reply-to-id']) || ($object_data['reply-to-id'] == './')) { $object_data['reply-to-id'] = $object_data['id']; } diff --git a/src/Util/JsonLD.php b/src/Util/JsonLD.php index cd3a6ec27..e2c2dddc1 100644 --- a/src/Util/JsonLD.php +++ b/src/Util/JsonLD.php @@ -93,6 +93,10 @@ class JsonLD 'dc' => (object)['@id' => 'http://purl.org/dc/terms/', '@type' => '@id'], 'toot' => (object)['@id' => 'http://joinmastodon.org/ns#', '@type' => '@id']]; + // Workaround for Nextcloud Social + // See issue https://github.com/nextcloud/social/issues/330 + $json['@context'][] = 'https://w3id.org/security/v1'; + // Trying to avoid memory problems with large content fields if (!empty($json['object']['source']['content'])) { $content = $json['object']['source']['content'];