]> git.mxchange.org Git - friendica.git/commitdiff
Standards
authorMichael <heluecht@pirati.ca>
Fri, 11 Dec 2020 20:20:27 +0000 (20:20 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 11 Dec 2020 20:20:27 +0000 (20:20 +0000)
src/Protocol/ActivityPub/Transmitter.php

index 378f4c9c640c7a414e0b6fe048912d077f940117..ed1ac43c76c81d0cb5e642bcbbbc91a13a6f50b2 100644 (file)
@@ -475,7 +475,8 @@ class Transmitter
         * @param integer $item_id
         * @return boolean "true" if the post is from ActivityPub
         */
-       private static function isAPPost(int $item_id) {
+       private static function isAPPost(int $item_id)
+       {
                if (empty($item_id)) {
                        return false;
                }
@@ -1048,33 +1049,31 @@ class Transmitter
                        return false;
                }
 
-               if (empty($type)) {
-                       $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
-                       $conversation = DBA::selectFirst('conversation', ['source'], $condition);
-                       if (DBA::isResult($conversation)) {
-                               $data = json_decode($conversation['source'], true);
-                               if (!empty($data['type'])) {
-                                       if (in_array($data['type'], ['Create', 'Update'])) {
-                                               if ($object_mode) {
-                                                       unset($data['@context']);
-                                                       unset($data['signature']);
-                                               }
-                                               Logger::info('Return stored conversation', ['item' => $item_id]);
-                                               return $data;
-                                       } elseif (in_array('as:' . $data['type'], Receiver::CONTENT_TYPES)) {
-                                               if (!empty($data['@context'])) {
-                                                       $context = $data['@context'];
-                                                       unset($data['@context']);
-                                               }
-                                               unset($data['actor']);
-                                               $object = $data;
+               $condition = ['item-uri' => $item['uri'], 'protocol' => Conversation::PARCEL_ACTIVITYPUB];
+               $conversation = DBA::selectFirst('conversation', ['source'], $condition);
+               if (!$item['origin'] && DBA::isResult($conversation)) {
+                       $data = json_decode($conversation['source'], true);
+                       if (!empty($data['type'])) {
+                               if (in_array($data['type'], ['Create', 'Update'])) {
+                                       if ($object_mode) {
+                                               unset($data['@context']);
+                                               unset($data['signature']);
                                        }
+                                       Logger::info('Return stored conversation', ['item' => $item_id]);
+                                       return $data;
+                               } elseif (in_array('as:' . $data['type'], Receiver::CONTENT_TYPES)) {
+                                       if (!empty($data['@context'])) {
+                                               $context = $data['@context'];
+                                               unset($data['@context']);
+                                       }
+                                       unset($data['actor']);
+                                       $object = $data;
                                }
                        }
-
-                       $type = self::getTypeOfItem($item);
                }
 
+               $type = self::getTypeOfItem($item);
+
                if (!$object_mode) {
                        $data = ['@context' => $context ?? ActivityPub::CONTEXT];