]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/ActivityPub/Processor.php
Merge pull request #11306 from annando/abstract-space
[friendica.git] / src / Protocol / ActivityPub / Processor.php
index b7ddc09f61b0856e5e5b760c39a81ff715a790d5..79d24d16024538b997b0050d12ad08df90e72d33 100644 (file)
@@ -526,6 +526,8 @@ class Processor
                self::storeFromBody($item);
                self::storeTags($item['uri-id'], $activity['tags']);
 
+               self::storeReceivers($item['uri-id'], $activity['receiver_urls'] ?? []);
+
                $item['location'] = $activity['location'];
 
                if (!empty($activity['latitude']) && !empty($activity['longitude'])) {
@@ -647,7 +649,12 @@ class Processor
                                        Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id']]);
                                        continue;
                                }
-                               if (!empty($activity['thread-children-type']) && in_array($activity['thread-children-type'], Receiver::ACTIVITY_TYPES)) {
+
+                               if (
+                                       !empty($activity['thread-children-type'])
+                                       && in_array($activity['thread-children-type'], Receiver::ACTIVITY_TYPES)
+                                       && DI::pConfig()->get($receiver, 'system', 'accept_only_sharer') != Item::COMPLETION_LIKE
+                               ) {
                                        Logger::info('Top level post from thread completion from a non sharer had been initiated via an activity, ignoring',
                                                ['type' => $activity['thread-children-type'], 'user' => $item['uid'], 'causer' => $item['causer-link'], 'author' => $activity['author'], 'url' => $item['uri']]);
                                        continue;
@@ -663,7 +670,7 @@ class Processor
                                }
                        }
 
-                       if (!$is_forum && DI::pConfig()->get($receiver, 'system', 'accept_only_sharer', false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT)) {
+                       if (!$is_forum && DI::pConfig()->get($receiver, 'system', 'accept_only_sharer') == Item::COMPLETION_NONE && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT)) {
                                $skip = !Contact::isSharingByURL($activity['author'], $receiver);
 
                                if ($skip && (($activity['type'] == 'as:Announce') || ($item['isForum'] ?? false))) {
@@ -751,6 +758,22 @@ class Processor
                }
        }
 
+       public static function storeReceivers(int $uriid, array $receivers)
+       {
+               foreach (['as:to' => Tag::TO, 'as:cc' => Tag::CC, 'as:bto' => Tag::BTO, 'as:bcc' => Tag::BCC] as $element => $type) {
+                       if (!empty($receivers[$element])) {
+                               foreach ($receivers[$element] as $receiver) {
+                                       if ($receiver == ActivityPub::PUBLIC_COLLECTION) {
+                                               $name = Receiver::PUBLIC_COLLECTION;
+                                       } else {
+                                               $name = trim(parse_url($receiver, PHP_URL_PATH), '/');
+                                       }
+                                       Tag::store($uriid, $type, $name, $receiver);
+                               }
+                       }
+               }
+       }
+
        /**
         * Creates an mail post
         *