]> git.mxchange.org Git - friendica.git/commitdiff
Option to store untrusted entries
authorMichael <heluecht@pirati.ca>
Sun, 24 Jul 2022 19:31:31 +0000 (19:31 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 24 Jul 2022 19:31:31 +0000 (19:31 +0000)
src/Protocol/ActivityPub/Receiver.php
static/defaults.config.php

index 84d1197514e96e8d3c1e728b31d1d0d33ec269b0..2655da9f0e3b11302f1071cbe4bf442ed76561fe 100644 (file)
@@ -273,6 +273,8 @@ class Receiver
        public static function prepareObjectData(array $activity, int $uid, bool $push, bool &$trust_source): array
        {
                $id = JsonLD::fetchElement($activity, '@id');
+               $object_id = JsonLD::fetchElement($activity, 'as:object', '@id');
+               
                if (!empty($id) && !$trust_source) {
                        $fetch_uid = $uid ?: self::getBestUserForActivity($activity);
 
@@ -283,7 +285,13 @@ class Receiver
                                if ($fetched_id == $id) {
                                        Logger::info('Activity had been fetched successfully', ['id' => $id]);
                                        $trust_source = true;
-                                       $activity = $object;
+                                       if ($id != $object_id) {
+                                               $activity = $object;
+                                       } else {
+                                               Logger::info('Fetched data is the object instead of the activity', ['id' => $id]);
+                                               unset($object['@context']);
+                                               $activity['as:object'] = $object;
+                                       }                                       
                                } else {
                                        Logger::info('Activity id is not equal', ['id' => $id, 'fetched' => $fetched_id]);
                                }
@@ -556,7 +564,9 @@ class Receiver
                        $object_data['object_activity'] = $activity;
                }
 
-               $object_data = Queue::add($object_data, $type, $uid, $http_signer, $push, $trust_source);
+               if ($trust_source || DI::config()->get('debug', 'ap_inbox_store_untrusted')) {
+                       $object_data = Queue::add($object_data, $type, $uid, $http_signer, $push, $trust_source);
+               }
 
                if (!$trust_source) {
                        Logger::info('Activity trust could not be achieved.',  ['id' => $object_data['object_id'], 'type' => $type, 'signer' => $signer, 'actor' => $actor, 'attributedTo' => $attributed_to]);
@@ -1830,29 +1840,6 @@ class Receiver
                unset($object_data['receiver'][-1]);
                unset($object_data['reception_type'][-1]);
 
-               // Common object data:
-
-               // Unhandled
-               // @context, type, actor, signature, mediaType, duration, replies, icon
-
-               // Also missing: (Defined in the standard, but currently unused)
-               // audience, preview, endTime, startTime, image
-
-               // Data in Notes:
-
-               // Unhandled
-               // contentMap, announcement_count, announcements, context_id, likes, like_count
-               // inReplyToStatusId, shares, quoteUrl, statusnetConversationId
-
-               // Data in video:
-
-               // To-Do?
-               // category, licence, language, commentsEnabled
-
-               // Unhandled
-               // views, waitTranscoding, state, support, subtitleLanguage
-               // likes, dislikes, shares, comments
-
                return $object_data;
        }
 }
index c01172d55a1be593c55aef39966b79ca76f18add..1876ea90d742985f4154b00546a51c397468d07c 100644 (file)
@@ -666,6 +666,10 @@ return [
                // Logs every call to /inbox as a JSON file in Friendica's temporary directory
                'ap_inbox_log' => false,
 
+               // ap_inbox_store_untrusted (Boolean)
+               // Store untrusted content in the inbox entries
+               'ap_inbox_store_untrusted' => false,
+
                // total_ap_delivery (Boolean)
                // Deliver via AP to every possible receiver and we suppress the delivery to these contacts with other protocols
                'total_ap_delivery' => false,