]> git.mxchange.org Git - friendica.git/commitdiff
Avoid thread completion on activities
authorMichael <heluecht@pirati.ca>
Sat, 12 Feb 2022 13:05:56 +0000 (13:05 +0000)
committerMichael <heluecht@pirati.ca>
Sat, 12 Feb 2022 13:05:56 +0000 (13:05 +0000)
src/Protocol/ActivityPub/Processor.php
src/Protocol/ActivityPub/Receiver.php

index 76f8cdb8507391eb15d719541d443407a26fa51f..b7ddc09f61b0856e5e5b760c39a81ff715a790d5 100644 (file)
@@ -306,7 +306,7 @@ class Processor
                        } else {
                                // Store the original actor in the "causer" fields to enable the check for ignored or blocked contacts
                                $item['causer-link'] = $item['owner-link'];
-                               $item['causer-id'] = $item['owner-id'];
+                               $item['causer-id']   = $item['owner-id'];
                                Logger::info('Use actor as causer.', ['id' => $item['owner-id'], 'actor' => $item['owner-link']]);
                        }
 
@@ -642,10 +642,16 @@ class Processor
                                continue;
                        }
 
-                       if (!($item['isForum'] ?? false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) &&
-                               ($item['post-reason'] == Item::PR_BCC) && !Contact::isSharingByURL($activity['author'], $receiver)) {
-                               Logger::info('Top level post via BCC from a non sharer, ignoring', ['uid' => $receiver, 'contact' => $item['contact-id']]);
-                               continue;
+                       if (!($item['isForum'] ?? false) && ($receiver != 0) && ($item['gravity'] == GRAVITY_PARENT) && !Contact::isSharingByURL($activity['author'], $receiver)) {
+                               if ($item['post-reason'] == Item::PR_BCC) {
+                                       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)) {
+                                       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;
+                               }
                        }
 
                        $is_forum = false;
@@ -887,6 +893,10 @@ class Processor
                        $ldactivity['thread-completion'] = Contact::getIdForURL($actor);
                }
 
+               if (!empty($child['type'])) {
+                       $ldactivity['thread-children-type'] = $child['type'];
+               }
+
                if (!empty($relay_actor) && !self::acceptIncomingMessage($ldactivity, $object['id'])) {
                        return '';
                }
index a28cc96170a1d7a5311fa873bf0a0af7bd7be5b7..3da53a033e8b4ef67d0b8eed5fc28801bf907394 100644 (file)
@@ -515,6 +515,9 @@ class Receiver
                if (!empty($activity['thread-completion'])) {
                        $object_data['thread-completion'] = $activity['thread-completion'];
                }
+               if (!empty($activity['thread-children-type'])) {
+                       $object_data['thread-children-type'] = $activity['thread-children-type'];
+               }
 
                // Internal flag for posts that arrived via relay
                if (!empty($activity['from-relay'])) {