]> git.mxchange.org Git - friendica.git/commitdiff
Location, coord and app are now processed as well
authorMichael <heluecht@pirati.ca>
Sat, 13 Oct 2018 21:37:39 +0000 (21:37 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 13 Oct 2018 21:37:39 +0000 (21:37 +0000)
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php

index 166530f472729d2312e5b79769035b541e3c5364..d77a0277fbd4b4b12f3fded4ddbec2b044a94f80 100644 (file)
@@ -212,8 +212,13 @@ class Processor
                $item['content-warning'] = HTML::toBBCode($activity['summary']);
                $item['body'] = self::convertMentions(HTML::toBBCode($activity['content']));
                $item['location'] = $activity['location'];
+
+               if (!empty($item['latitude']) && !empty($item['longitude'])) {
+                       $item['coord'] = $item['latitude'] . ' ' . $item['longitude'];
+               }
+
                $item['tag'] = self::constructTagList($activity['tags'], $activity['sensitive']);
-               $item['app'] = $activity['service'];
+               $item['app'] = $activity['generator'];
                $item['plink'] = defaults($activity, 'alternate-url', $item['uri']);
                $item['diaspora_signed_text'] = defaults($activity, 'diaspora:comment', '');
 
index 773d45c83ae951ddf070c82710abd481c204ee1e..cde197b0c41e421044e3ac238bf8dd927c24de8b 100644 (file)
@@ -25,10 +25,6 @@ use Friendica\Util\DateTimeFormat;
  * - Event
  * - Undo Announce
  *
- * Missing object fields:
- * - Location
- * - Generator
- *
  * Check what this is meant to do:
  * - Add
  * - Block
@@ -517,24 +513,15 @@ class Receiver
        private static function addActivityFields($object_data, $activity)
        {
                if (!empty($activity['published']) && empty($object_data['published'])) {
-                       $object_data['published'] = JsonLD::fetchElement($activity, 'published', '@value');
-               }
-
-               if (!empty($activity['updated']) && empty($object_data['updated'])) {
-                       $object_data['updated'] = JsonLD::fetchElement($activity, 'updated', '@value');
+                       $object_data['published'] = JsonLD::fetchElement($activity, 'as:published', '@value');
                }
 
                if (!empty($activity['diaspora:guid']) && empty($object_data['diaspora:guid'])) {
                        $object_data['diaspora:guid'] = JsonLD::fetchElement($activity, 'diaspora:guid');
                }
 
-               if (!empty($activity['inReplyTo']) && empty($object_data['parent-uri'])) {
-                       $object_data['parent-uri'] = JsonLD::fetchElement($activity, 'inReplyTo');
-               }
+               $object_data['service'] = JsonLD::fetchElement($activity, 'as:instrument', 'as:name', '@type', 'as:Service');
 
-               if (!empty($activity['instrument'])) {
-                       $object_data['service'] = JsonLD::fetchElement($activity, 'instrument', 'name', 'type', 'Service');
-               }
                return $object_data;
        }
 
@@ -700,10 +687,13 @@ class Receiver
                $object_data['content'] = JsonLD::fetchElement($object, 'as:content');
                $object_data['source'] = JsonLD::fetchElement($object, 'as:source', 'as:content', 'as:mediaType', 'text/bbcode');
                $object_data['location'] = JsonLD::fetchElement($object, 'as:location', 'as:name', '@type', 'as:Place');
+               $object_data['latitude'] = JsonLD::fetchElement($object, 'as:location', 'as:latitude', '@type', 'as:Place');
+               $object_data['latitude'] = JsonLD::fetchElement($object_data, 'latitude', '@value');
+               $object_data['longitude'] = JsonLD::fetchElement($object, 'as:location', 'as:longitude', '@type', 'as:Place');
+               $object_data['longitude'] = JsonLD::fetchElement($object_data, 'longitude', '@value');
                $object_data['attachments'] = self::processAttachments(JsonLD::fetchElementArray($object, 'as:attachment'));
                $object_data['tags'] = self::processTags(JsonLD::fetchElementArray($object, 'as:tag'));
-//             $object_data['service'] = JsonLD::fetchElement($object, 'instrument', 'name', 'type', 'Service'); // todo
-               $object_data['service'] = null;
+               $object_data['generator'] = JsonLD::fetchElement($object, 'as:generator', 'as:name', '@type', 'as:Application');
                $object_data['alternate-url'] = JsonLD::fetchElement($object, 'as:url');
 
                // Special treatment for Hubzilla links
@@ -723,7 +713,7 @@ class Receiver
                // @context, type, actor, signature, mediaType, duration, replies, icon
 
                // Also missing: (Defined in the standard, but currently unused)
-               // audience, preview, endTime, startTime, generator, image
+               // audience, preview, endTime, startTime, image
 
                // Data in Notes: