]> git.mxchange.org Git - friendica.git/commitdiff
Store the raw data in a different way
authorMichael <heluecht@pirati.ca>
Fri, 28 Feb 2020 09:21:40 +0000 (09:21 +0000)
committerMichael <heluecht@pirati.ca>
Fri, 28 Feb 2020 09:21:40 +0000 (09:21 +0000)
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php

index 089d41729f5180b1c53c18729f102e628818b275..67cc2e290552c82c9e0449840c6bc286c7b7da60 100644 (file)
@@ -448,6 +448,10 @@ class Processor
                $item['owner-link'] = $activity['actor'];
                $item['owner-id'] = Contact::getIdForURL($activity['actor'], 0, true);
 
+               if (!empty($activity['raw'])) {
+                       $item['source'] = $activity['raw'];
+               }
+
                $isForum = false;
 
                if (!empty($activity['thread-completion'])) {
index 7d25d94f1788abcfa9e53333b6f9a78552092bce..b7622e962fc57d95dfd91add10c560a6bb28ac63 100644 (file)
@@ -303,33 +303,6 @@ class Receiver
                return 0;
        }
 
-       /**
-        * Store the unprocessed data into the conversation table
-        * This has to be done outside the regular function,
-        * since we store everything - not only item posts.
-        *
-        * @param array  $activity Array with activity data
-        * @param string $body     The raw message
-        * @throws \Exception
-        */
-       private static function storeConversation($activity, $body)
-       {
-               if (empty($body) || empty($activity['id'])) {
-                       return;
-               }
-
-               $conversation = [
-                       'protocol' => Conversation::PARCEL_ACTIVITYPUB,
-                       'item-uri' => $activity['id'],
-                       'reply-to-uri' => $activity['reply-to-id'] ?? '',
-                       'conversation-href' => $activity['context'] ?? '',
-                       'conversation-uri' => $activity['conversation'] ?? '',
-                       'source' => $body,
-                       'received' => DateTimeFormat::utcNow()];
-
-               DBA::insert('conversation', $conversation, true);
-       }
-
        /**
         * Processes the activity object
         *
@@ -380,9 +353,9 @@ class Receiver
                        return;
                }
 
-               // Only store content related stuff - and no announces, since they possibly overwrite the original content
-               if (in_array($object_data['object_type'], self::CONTENT_TYPES) && ($type != 'as:Announce')) {
-                       self::storeConversation($object_data, $body);
+               if (!empty($body)) {
+                       $object_data['raw'] = $body;
+                       $object_data['protocol'] = Conversation::PARCEL_ACTIVITYPUB;
                }
 
                // Internal flag for thread completion. See Processor.php