3 * @file src/Protocol/ActivityPub/Receiver.php
5 namespace Friendica\Protocol\ActivityPub;
7 use Friendica\Database\DBA;
8 use Friendica\Util\HTTPSignature;
9 use Friendica\Core\Logger;
10 use Friendica\Core\Protocol;
11 use Friendica\Model\Contact;
12 use Friendica\Model\APContact;
13 use Friendica\Model\Item;
14 use Friendica\Model\User;
15 use Friendica\Util\JsonLD;
16 use Friendica\Util\LDSignature;
17 use Friendica\Protocol\ActivityPub;
18 use Friendica\Model\Conversation;
19 use Friendica\Util\DateTimeFormat;
22 * @brief ActivityPub Receiver Protocol class
27 * Check what this is meant to do:
36 const PUBLIC_COLLECTION = 'as:Public';
37 const ACCOUNT_TYPES = ['as:Person', 'as:Organization', 'as:Service', 'as:Group', 'as:Application'];
38 const CONTENT_TYPES = ['as:Note', 'as:Article', 'as:Video', 'as:Image', 'as:Event'];
39 const ACTIVITY_TYPES = ['as:Like', 'as:Dislike', 'as:Accept', 'as:Reject', 'as:TentativeAccept'];
42 * Checks if the web request is done for the AP protocol
46 public static function isRequest()
48 return stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/activity+json') ||
49 stristr(defaults($_SERVER, 'HTTP_ACCEPT', ''), 'application/ld+json');
53 * Checks incoming message from the inbox
57 * @param integer $uid User ID
59 public static function processInbox($body, $header, $uid)
61 $http_signer = HTTPSignature::getSigner($body, $header);
62 if (empty($http_signer)) {
63 Logger::log('Invalid HTTP signature, message will be discarded.', Logger::DEBUG);
66 Logger::log('HTTP signature is signed by ' . $http_signer, Logger::DEBUG);
69 $activity = json_decode($body, true);
71 if (empty($activity)) {
72 Logger::log('Invalid body.', Logger::DEBUG);
76 $ldactivity = JsonLD::compact($activity);
78 $actor = JsonLD::fetchElement($ldactivity, 'as:actor');
80 Logger::log('Message for user ' . $uid . ' is from actor ' . $actor, Logger::DEBUG);
82 if (LDSignature::isSigned($activity)) {
83 $ld_signer = LDSignature::getSigner($activity);
84 if (empty($ld_signer)) {
85 Logger::log('Invalid JSON-LD signature from ' . $actor, Logger::DEBUG);
87 if (!empty($ld_signer && ($actor == $http_signer))) {
88 Logger::log('The HTTP and the JSON-LD signature belong to ' . $ld_signer, Logger::DEBUG);
90 } elseif (!empty($ld_signer)) {
91 Logger::log('JSON-LD signature is signed by ' . $ld_signer, Logger::DEBUG);
93 } elseif ($actor == $http_signer) {
94 Logger::log('Bad JSON-LD signature, but HTTP signer fits the actor.', Logger::DEBUG);
97 Logger::log('Invalid JSON-LD signature and the HTTP signer is different.', Logger::DEBUG);
98 $trust_source = false;
100 } elseif ($actor == $http_signer) {
101 Logger::log('Trusting post without JSON-LD signature, The actor fits the HTTP signer.', Logger::DEBUG);
102 $trust_source = true;
104 Logger::log('No JSON-LD signature, different actor.', Logger::DEBUG);
105 $trust_source = false;
108 self::processActivity($ldactivity, $body, $uid, $trust_source);
112 * Fetches the object type for a given object id
114 * @param array $activity
115 * @param string $object_id Object ID of the the provided object
116 * @param integer $uid User ID
118 * @return string with object type
120 private static function fetchObjectType($activity, $object_id, $uid = 0)
122 if (!empty($activity['as:object'])) {
123 $object_type = JsonLD::fetchElement($activity['as:object'], '@type');
124 if (!empty($object_type)) {
129 if (Item::exists(['uri' => $object_id, 'gravity' => [GRAVITY_PARENT, GRAVITY_COMMENT]])) {
130 // We just assume "note" since it doesn't make a difference for the further processing
134 $profile = APContact::getByURL($object_id);
135 if (!empty($profile['type'])) {
136 return 'as:' . $profile['type'];
139 $data = ActivityPub::fetchContent($object_id, $uid);
141 $object = JsonLD::compact($data);
142 $type = JsonLD::fetchElement($object, '@type');
152 * Prepare the object array
154 * @param array $activity
155 * @param integer $uid User ID
156 * @param $trust_source
158 * @return array with object data
160 private static function prepareObjectData($activity, $uid, &$trust_source)
162 $actor = JsonLD::fetchElement($activity, 'as:actor');
164 Logger::log('Empty actor', Logger::DEBUG);
168 $type = JsonLD::fetchElement($activity, '@type');
170 // Fetch all receivers from to, cc, bto and bcc
171 $receivers = self::getReceivers($activity, $actor);
173 // When it is a delivery to a personal inbox we add that user to the receivers
175 $additional = ['uid:' . $uid => $uid];
176 $receivers = array_merge($receivers, $additional);
178 // We possibly need some user to fetch private content,
179 // so we fetch the first out ot the list.
180 $uid = self::getFirstUserFromReceivers($receivers);
183 Logger::log('Receivers: ' . $uid . ' - ' . json_encode($receivers), Logger::DEBUG);
185 $object_id = JsonLD::fetchElement($activity, 'as:object');
186 if (empty($object_id)) {
187 Logger::log('No object found', Logger::DEBUG);
191 $object_type = self::fetchObjectType($activity, $object_id, $uid);
193 // Fetch the content only on activities where this matters
194 if (in_array($type, ['as:Create', 'as:Update', 'as:Announce'])) {
195 if ($type == 'as:Announce') {
196 $trust_source = false;
198 $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source, $uid);
199 if (empty($object_data)) {
200 Logger::log("Object data couldn't be processed", Logger::DEBUG);
203 // We had been able to retrieve the object data - so we can trust the source
204 $trust_source = true;
205 } elseif (in_array($type, ['as:Like', 'as:Dislike'])) {
206 // Create a mostly empty array out of the activity data (instead of the object).
207 // This way we later don't have to check for the existence of ech individual array element.
208 $object_data = self::processObject($activity);
209 $object_data['name'] = $type;
210 $object_data['author'] = JsonLD::fetchElement($activity, 'as:actor');
211 $object_data['object_id'] = $object_id;
212 $object_data['object_type'] = ''; // Since we don't fetch the object, we don't know the type
215 $object_data['id'] = JsonLD::fetchElement($activity, '@id');
216 $object_data['object_id'] = JsonLD::fetchElement($activity, 'as:object');
217 $object_data['object_actor'] = JsonLD::fetchElement($activity['as:object'], 'as:actor');
218 $object_data['object_object'] = JsonLD::fetchElement($activity['as:object'], 'as:object');
219 $object_data['object_type'] = JsonLD::fetchElement($activity['as:object'], '@type');
221 // An Undo is done on the object of an object, so we need that type as well
222 if ($type == 'as:Undo') {
223 $object_data['object_object_type'] = self::fetchObjectType([], $object_data['object_object'], $uid);
227 $object_data = self::addActivityFields($object_data, $activity);
229 if (empty($object_data['object_type'])) {
230 $object_data['object_type'] = $object_type;
233 $object_data['type'] = $type;
234 $object_data['actor'] = $actor;
235 $object_data['receiver'] = array_merge(defaults($object_data, 'receiver', []), $receivers);
237 Logger::log('Processing ' . $object_data['type'] . ' ' . $object_data['object_type'] . ' ' . $object_data['id'], Logger::DEBUG);
243 * Fetches the first user id from the receiver array
245 * @param array $receivers Array with receivers
246 * @return integer user id;
248 public static function getFirstUserFromReceivers($receivers)
250 foreach ($receivers as $receiver) {
251 if (!empty($receiver)) {
259 * Store the unprocessed data into the conversation table
260 * This has to be done outside the regular function,
261 * since we store everything - not only item posts.
263 * @param array $activity Array with activity data
264 * @param string $body The raw message
266 private static function storeConversation($activity, $body)
268 if (empty($body) || empty($activity['id'])) {
273 'protocol' => Conversation::PARCEL_ACTIVITYPUB,
274 'item-uri' => $activity['id'],
275 'reply-to-uri' => defaults($activity, 'reply-to-id', ''),
276 'conversation-href' => defaults($activity, 'context', ''),
277 'conversation-uri' => defaults($activity, 'conversation', ''),
279 'received' => DateTimeFormat::utcNow()];
281 DBA::insert('conversation', $conversation, true);
285 * Processes the activity object
287 * @param array $activity Array with activity data
288 * @param string $body
289 * @param integer $uid User ID
290 * @param boolean $trust_source Do we trust the source?
292 public static function processActivity($activity, $body = '', $uid = null, $trust_source = false)
294 $type = JsonLD::fetchElement($activity, '@type');
296 Logger::log('Empty type', Logger::DEBUG);
300 if (!JsonLD::fetchElement($activity, 'as:object')) {
301 Logger::log('Empty object', Logger::DEBUG);
305 if (!JsonLD::fetchElement($activity, 'as:actor')) {
306 Logger::log('Empty actor', Logger::DEBUG);
311 // $trust_source is called by reference and is set to true if the content was retrieved successfully
312 $object_data = self::prepareObjectData($activity, $uid, $trust_source);
313 if (empty($object_data)) {
314 Logger::log('No object data found', Logger::DEBUG);
318 if (!$trust_source) {
319 Logger::log('No trust for activity type "' . $type . '", so we quit now.', Logger::DEBUG);
323 self::storeConversation($object_data, $body);
325 // Internal flag for thread completion. See Processor.php
326 if (!empty($activity['thread-completion'])) {
327 $object_data['thread-completion'] = $activity['thread-completion'];
333 if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
334 ActivityPub\Processor::createItem($object_data);
339 if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
340 ActivityPub\Processor::createActivity($object_data, ACTIVITY_LIKE);
345 if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
346 ActivityPub\Processor::createActivity($object_data, ACTIVITY_DISLIKE);
350 case 'as:TentativeAccept':
351 if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
352 ActivityPub\Processor::createActivity($object_data, ACTIVITY_ATTENDMAYBE);
357 if (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
358 ActivityPub\Processor::updateItem($object_data);
359 } elseif (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
360 ActivityPub\Processor::updatePerson($object_data, $body);
365 if ($object_data['object_type'] == 'as:Tombstone') {
366 ActivityPub\Processor::deleteItem($object_data, $body);
367 } elseif (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
368 ActivityPub\Processor::deletePerson($object_data, $body);
373 if (in_array($object_data['object_type'], self::ACCOUNT_TYPES)) {
374 ActivityPub\Processor::followUser($object_data);
379 if ($object_data['object_type'] == 'as:Follow') {
380 ActivityPub\Processor::acceptFollowUser($object_data);
381 } elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
382 ActivityPub\Processor::createActivity($object_data, ACTIVITY_ATTEND);
387 if ($object_data['object_type'] == 'as:Follow') {
388 ActivityPub\Processor::rejectFollowUser($object_data);
389 } elseif (in_array($object_data['object_type'], self::CONTENT_TYPES)) {
390 ActivityPub\Processor::createActivity($object_data, ACTIVITY_ATTENDNO);
395 if (($object_data['object_type'] == 'as:Follow') &&
396 in_array($object_data['object_object_type'], self::ACCOUNT_TYPES)) {
397 ActivityPub\Processor::undoFollowUser($object_data);
398 } elseif (($object_data['object_type'] == 'as:Accept') &&
399 in_array($object_data['object_object_type'], self::ACCOUNT_TYPES)) {
400 ActivityPub\Processor::rejectFollowUser($object_data);
401 } elseif (in_array($object_data['object_type'], self::ACTIVITY_TYPES) &&
402 in_array($object_data['object_object_type'], self::CONTENT_TYPES)) {
403 ActivityPub\Processor::undoActivity($object_data);
408 Logger::log('Unknown activity: ' . $type . ' ' . $object_data['object_type'], Logger::DEBUG);
414 * Fetch the receiver list from an activity array
416 * @param array $activity
417 * @param string $actor
420 * @return array with receivers (user id)
422 private static function getReceivers($activity, $actor, $tags = [])
426 // When it is an answer, we inherite the receivers from the parent
427 $replyto = JsonLD::fetchElement($activity, 'as:inReplyTo');
428 if (!empty($replyto)) {
429 $parents = Item::select(['uid'], ['uri' => $replyto]);
430 while ($parent = Item::fetch($parents)) {
431 $receivers['uid:' . $parent['uid']] = $parent['uid'];
435 if (!empty($actor)) {
436 $profile = APContact::getByURL($actor);
437 $followers = defaults($profile, 'followers', '');
439 Logger::log('Actor: ' . $actor . ' - Followers: ' . $followers, Logger::DEBUG);
441 Logger::log('Empty actor', Logger::DEBUG);
445 foreach (['as:to', 'as:cc', 'as:bto', 'as:bcc'] as $element) {
446 $receiver_list = JsonLD::fetchElementArray($activity, $element);
447 if (empty($receiver_list)) {
451 foreach ($receiver_list as $receiver) {
452 if ($receiver == self::PUBLIC_COLLECTION) {
453 $receivers['uid:0'] = 0;
456 if (($receiver == self::PUBLIC_COLLECTION) && !empty($actor)) {
457 // This will most likely catch all OStatus connections to Mastodon
458 $condition = ['alias' => [$actor, normalise_link($actor)], 'rel' => [Contact::SHARING, Contact::FRIEND]
459 , 'archive' => false, 'pending' => false];
460 $contacts = DBA::select('contact', ['uid'], $condition);
461 while ($contact = DBA::fetch($contacts)) {
462 if ($contact['uid'] != 0) {
463 $receivers['uid:' . $contact['uid']] = $contact['uid'];
466 DBA::close($contacts);
469 if (in_array($receiver, [$followers, self::PUBLIC_COLLECTION]) && !empty($actor)) {
470 $receivers = array_merge($receivers, self::getReceiverForActor($actor, $tags));
474 // Fetching all directly addressed receivers
475 $condition = ['self' => true, 'nurl' => normalise_link($receiver)];
476 $contact = DBA::selectFirst('contact', ['uid', 'contact-type'], $condition);
477 if (!DBA::isResult($contact)) {
481 // Check if the potential receiver is following the actor
482 // Exception: The receiver is targetted via "to" or this is a comment
483 if ((($element != 'as:to') && empty($replyto)) || ($contact['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY)) {
484 $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
485 $condition = ['nurl' => normalise_link($actor), 'rel' => [Contact::SHARING, Contact::FRIEND],
486 'network' => $networks, 'archive' => false, 'pending' => false, 'uid' => $contact['uid']];
488 // Forum posts are only accepted from forum contacts
489 if ($contact['contact-type'] == Contact::ACCOUNT_TYPE_COMMUNITY) {
490 $condition['rel'] = [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER];
493 if (!DBA::exists('contact', $condition)) {
498 $receivers['uid:' . $contact['uid']] = $contact['uid'];
502 self::switchContacts($receivers, $actor);
508 * Fetch the receiver list of a given actor
510 * @param string $actor
513 * @return array with receivers (user id)
515 public static function getReceiverForActor($actor, $tags)
518 $networks = [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
519 $condition = ['nurl' => normalise_link($actor), 'rel' => [Contact::SHARING, Contact::FRIEND, Contact::FOLLOWER],
520 'network' => $networks, 'archive' => false, 'pending' => false];
521 $contacts = DBA::select('contact', ['uid', 'rel'], $condition);
522 while ($contact = DBA::fetch($contacts)) {
523 if (self::isValidReceiverForActor($contact, $actor, $tags)) {
524 $receivers['uid:' . $contact['uid']] = $contact['uid'];
527 DBA::close($contacts);
532 * Tests if the contact is a valid receiver for this actor
534 * @param array $contact
535 * @param string $actor
538 * @return array with receivers (user id)
540 private static function isValidReceiverForActor($contact, $actor, $tags)
542 // Public contacts are no valid receiver
543 if ($contact['uid'] == 0) {
547 // Are we following the contact? Then this is a valid receiver
548 if (in_array($contact['rel'], [Contact::SHARING, Contact::FRIEND])) {
552 // When the possible receiver isn't a community, then it is no valid receiver
553 $owner = User::getOwnerDataById($contact['uid']);
554 if (empty($owner) || ($owner['contact-type'] != Contact::ACCOUNT_TYPE_COMMUNITY)) {
558 // Is the community account tagged?
559 foreach ($tags as $tag) {
560 if ($tag['type'] != 'Mention') {
564 if ($tag['href'] == $owner['url']) {
573 * Switches existing contacts to ActivityPub
575 * @param integer $cid Contact ID
576 * @param integer $uid User ID
577 * @param string $url Profile URL
579 public static function switchContact($cid, $uid, $url)
581 $profile = ActivityPub::probeProfile($url);
582 if (empty($profile)) {
586 Logger::log('Switch contact ' . $cid . ' (' . $profile['url'] . ') for user ' . $uid . ' to ActivityPub');
588 $photo = defaults($profile, 'photo', null);
589 unset($profile['photo']);
590 unset($profile['baseurl']);
592 $profile['nurl'] = normalise_link($profile['url']);
593 DBA::update('contact', $profile, ['id' => $cid]);
595 Contact::updateAvatar($photo, $uid, $cid);
597 // Send a new follow request to be sure that the connection still exists
598 if (($uid != 0) && DBA::exists('contact', ['id' => $cid, 'rel' => [Contact::SHARING, Contact::FRIEND]])) {
599 ActivityPub\Transmitter::sendActivity('Follow', $profile['url'], $uid);
600 Logger::log('Send a new follow request to ' . $profile['url'] . ' for user ' . $uid, Logger::DEBUG);
610 private static function switchContacts($receivers, $actor)
616 foreach ($receivers as $receiver) {
617 $contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'nurl' => normalise_link($actor)]);
618 if (DBA::isResult($contact)) {
619 self::switchContact($contact['id'], $receiver, $actor);
622 $contact = DBA::selectFirst('contact', ['id'], ['uid' => $receiver, 'network' => Protocol::OSTATUS, 'alias' => [normalise_link($actor), $actor]]);
623 if (DBA::isResult($contact)) {
624 self::switchContact($contact['id'], $receiver, $actor);
632 * @param $object_data
633 * @param array $activity
637 private static function addActivityFields($object_data, $activity)
639 if (!empty($activity['published']) && empty($object_data['published'])) {
640 $object_data['published'] = JsonLD::fetchElement($activity, 'as:published', '@value');
643 if (!empty($activity['diaspora:guid']) && empty($object_data['diaspora:guid'])) {
644 $object_data['diaspora:guid'] = JsonLD::fetchElement($activity, 'diaspora:guid');
647 $object_data['service'] = JsonLD::fetchElement($activity, 'as:instrument', 'as:name', '@type', 'as:Service');
653 * Fetches the object data from external ressources if needed
655 * @param string $object_id Object ID of the the provided object
656 * @param array $object The provided object array
657 * @param boolean $trust_source Do we trust the provided object?
658 * @param integer $uid User ID for the signature that we use to fetch data
660 * @return array with trusted and valid object data
662 private static function fetchObject($object_id, $object = [], $trust_source = false, $uid = 0)
664 // By fetching the type we check if the object is complete.
665 $type = JsonLD::fetchElement($object, '@type');
667 if (!$trust_source || empty($type)) {
668 $data = ActivityPub::fetchContent($object_id, $uid);
670 $object = JsonLD::compact($data);
671 Logger::log('Fetched content for ' . $object_id, Logger::DEBUG);
673 Logger::log('Empty content for ' . $object_id . ', check if content is available locally.', Logger::DEBUG);
675 $item = Item::selectFirst([], ['uri' => $object_id]);
676 if (!DBA::isResult($item)) {
677 Logger::log('Object with url ' . $object_id . ' was not found locally.', Logger::DEBUG);
680 Logger::log('Using already stored item for url ' . $object_id, Logger::DEBUG);
681 $data = ActivityPub\Transmitter::createNote($item);
682 $object = JsonLD::compact($data);
685 Logger::log('Using original object for url ' . $object_id, Logger::DEBUG);
688 $type = JsonLD::fetchElement($object, '@type');
691 Logger::log('Empty type', Logger::DEBUG);
695 if (in_array($type, self::CONTENT_TYPES)) {
696 return self::processObject($object);
699 if ($type == 'as:Announce') {
700 $object_id = JsonLD::fetchElement($object, 'object');
701 if (empty($object_id)) {
704 return self::fetchObject($object_id, [], false, $uid);
707 Logger::log('Unhandled object type: ' . $type, Logger::DEBUG);
711 * Convert tags from JSON-LD format into a simplified format
713 * @param array $tags Tags in JSON-LD format
715 * @return array with tags in a simplified format
717 private static function processTags($tags)
725 foreach ($tags as $tag) {
730 $taglist[] = ['type' => str_replace('as:', '', JsonLD::fetchElement($tag, '@type')),
731 'href' => JsonLD::fetchElement($tag, 'as:href'),
732 'name' => JsonLD::fetchElement($tag, 'as:name')];
738 * Convert attachments from JSON-LD format into a simplified format
740 * @param array $attachments Attachments in JSON-LD format
742 * @return array with attachmants in a simplified format
744 private static function processAttachments($attachments)
748 if (empty($attachments)) {
752 foreach ($attachments as $attachment) {
753 if (empty($attachment)) {
757 $attachlist[] = ['type' => str_replace('as:', '', JsonLD::fetchElement($attachment, '@type')),
758 'mediaType' => JsonLD::fetchElement($attachment, 'as:mediaType'),
759 'name' => JsonLD::fetchElement($attachment, 'as:name'),
760 'url' => JsonLD::fetchElement($attachment, 'as:url')];
766 * Fetches data from the object part of an activity
768 * @param array $object
772 private static function processObject($object)
774 if (!JsonLD::fetchElement($object, '@id')) {
779 $object_data['object_type'] = JsonLD::fetchElement($object, '@type');
780 $object_data['id'] = JsonLD::fetchElement($object, '@id');
782 $object_data['reply-to-id'] = JsonLD::fetchElement($object, 'as:inReplyTo');
784 if (empty($object_data['reply-to-id'])) {
785 $object_data['reply-to-id'] = $object_data['id'];
788 $object_data['published'] = JsonLD::fetchElement($object, 'as:published', '@value');
789 $object_data['updated'] = JsonLD::fetchElement($object, 'as:updated', '@value');
791 if (empty($object_data['updated'])) {
792 $object_data['updated'] = $object_data['published'];
795 if (empty($object_data['published']) && !empty($object_data['updated'])) {
796 $object_data['published'] = $object_data['updated'];
799 $actor = JsonLD::fetchElement($object, 'as:attributedTo');
801 $actor = JsonLD::fetchElement($object, 'as:actor');
804 $object_data['diaspora:guid'] = JsonLD::fetchElement($object, 'diaspora:guid');
805 $object_data['diaspora:comment'] = JsonLD::fetchElement($object, 'diaspora:comment');
806 $object_data['diaspora:like'] = JsonLD::fetchElement($object, 'diaspora:like');
807 $object_data['actor'] = $object_data['author'] = $actor;
808 $object_data['context'] = JsonLD::fetchElement($object, 'as:context');
809 $object_data['conversation'] = JsonLD::fetchElement($object, 'ostatus:conversation');
810 $object_data['sensitive'] = JsonLD::fetchElement($object, 'as:sensitive');
811 $object_data['name'] = JsonLD::fetchElement($object, 'as:name');
812 $object_data['summary'] = JsonLD::fetchElement($object, 'as:summary');
813 $object_data['content'] = JsonLD::fetchElement($object, 'as:content');
814 $object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode');
815 $object_data['start-time'] = JsonLD::fetchElement($object, 'as:startTime', '@value');
816 $object_data['end-time'] = JsonLD::fetchElement($object, 'as:endTime', '@value');
817 $object_data['location'] = JsonLD::fetchElement($object, 'as:location', 'as:name', '@type', 'as:Place');
818 $object_data['latitude'] = JsonLD::fetchElement($object, 'as:location', 'as:latitude', '@type', 'as:Place');
819 $object_data['latitude'] = JsonLD::fetchElement($object_data, 'latitude', '@value');
820 $object_data['longitude'] = JsonLD::fetchElement($object, 'as:location', 'as:longitude', '@type', 'as:Place');
821 $object_data['longitude'] = JsonLD::fetchElement($object_data, 'longitude', '@value');
822 $object_data['attachments'] = self::processAttachments(JsonLD::fetchElementArray($object, 'as:attachment'));
823 $object_data['tags'] = self::processTags(JsonLD::fetchElementArray($object, 'as:tag'));
824 $object_data['generator'] = JsonLD::fetchElement($object, 'as:generator', 'as:name', '@type', 'as:Application');
825 $object_data['alternate-url'] = JsonLD::fetchElement($object, 'as:url');
827 // Special treatment for Hubzilla links
828 if (is_array($object_data['alternate-url'])) {
829 $object_data['alternate-url'] = JsonLD::fetchElement($object_data['alternate-url'], 'as:href');
831 if (!is_string($object_data['alternate-url'])) {
832 $object_data['alternate-url'] = JsonLD::fetchElement($object['as:url'], 'as:href');
836 $object_data['receiver'] = self::getReceivers($object, $object_data['actor'], $object_data['tags']);
838 // Common object data:
841 // @context, type, actor, signature, mediaType, duration, replies, icon
843 // Also missing: (Defined in the standard, but currently unused)
844 // audience, preview, endTime, startTime, image
849 // contentMap, announcement_count, announcements, context_id, likes, like_count
850 // inReplyToStatusId, shares, quoteUrl, statusnetConversationId
855 // category, licence, language, commentsEnabled
858 // views, waitTranscoding, state, support, subtitleLanguage
859 // likes, dislikes, shares, comments