]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Receiver.php
Raw content is now stored with announce messages as well
[friendica.git] / src / Protocol / ActivityPub / Receiver.php
index 39655f45d7f5ed05045c674ca01133b171bed27f..21aba50944f7448bcc9b9411bf86e150526582e2 100644 (file)
@@ -174,9 +174,10 @@ class Receiver
        /**
         * Prepare the object array
         *
-        * @param array   $activity
-        * @param integer $uid User ID
-        * @param         $trust_source
+        * @param array   $activity     Array with activity data
+        * @param integer $uid          User ID
+        * @param boolean $push         Message had been pushed to our system
+        * @param boolean $trust_source Do we trust the source?
         *
         * @return array with object data
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
@@ -224,7 +225,6 @@ class Receiver
                if (in_array($type, ['as:Create', 'as:Update', 'as:Announce'])) {
                        if ($type == 'as:Announce') {
                                $trust_source = false;
-                               $push = false;
                        }
                        $object_data = self::fetchObject($object_id, $activity['as:object'], $trust_source, $uid);
                        if (empty($object_data)) {
@@ -233,7 +233,12 @@ class Receiver
                        }
 
                        $object_data['object_id'] = $object_id;
-                       $object_data['push'] = $push;
+
+                       if ($type == 'as:Announce') {
+                               $object_data['push'] = false;
+                       } else {
+                               $object_data['push'] = $push;
+                       }
 
                        // Test if it is an answer to a mail
                        if (DBA::exists('mail', ['uri' => $object_data['reply-to-id']])) {
@@ -312,6 +317,7 @@ class Receiver
         * @param string  $body
         * @param integer $uid          User ID
         * @param boolean $trust_source Do we trust the source?
+        * @param boolean $push         Message had been pushed to our system
         * @throws \Exception
         */
        public static function processActivity($activity, $body = '', $uid = null, $trust_source = false, $push = false)
@@ -355,7 +361,7 @@ class Receiver
                        return;
                }
 
-               if (!empty($body)) {
+               if (!empty($body) && empty($object_data['raw'])) {
                        $object_data['raw'] = $body;
                }
 
@@ -393,6 +399,11 @@ class Receiver
                                                $announce_object_data['author'] = JsonLD::fetchElement($activity, 'as:actor', '@id');
                                                $announce_object_data['object_id'] = $object_data['object_id'];
                                                $announce_object_data['object_type'] = $object_data['object_type'];
+                                               $announce_object_data['push'] = $push;
+
+                                               if (!empty($body)) {
+                                                       $announce_object_data['raw'] = $body;
+                                               }
 
                                                ActivityPub\Processor::createActivity($announce_object_data, Activity::ANNOUNCE);
                                        }
@@ -782,7 +793,12 @@ class Receiver
                }
 
                if (in_array($type, self::CONTENT_TYPES)) {
-                       return self::processObject($object);
+                       $object_data = self::processObject($object);
+
+                       if (!empty($data)) {
+                               $object_data['raw'] = json_encode($data);
+                       }
+                       return $object_data;
                }
 
                if ($type == 'as:Announce') {