]> git.mxchange.org Git - friendica.git/commitdiff
Set the owner for group posts
authorMichael <heluecht@pirati.ca>
Sun, 18 Jun 2023 16:52:49 +0000 (16:52 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 18 Jun 2023 16:52:49 +0000 (16:52 +0000)
src/Protocol/ActivityPub/Processor.php

index ac2e719718796b7c0894e3d364f71f0771a28808..2db9f925a945c34d9f730ba1810c93b69f9f63b9 100644 (file)
@@ -437,6 +437,18 @@ class Processor
                        $item['isGroup'] = ($actor['type'] ?? 'Person') == 'Group';
                }
 
+               if (!$item['isGroup'] && !empty($activity['receiver_urls']['as:audience'])) {
+                       foreach ($activity['receiver_urls']['as:audience'] as $audience) {
+                               $actor = APContact::getByURL($audience, false);
+                               if (($actor['type'] ?? 'Person') == 'Group') {
+                                       Logger::debug('Set owner to audience', ['audience' => $audience, 'actor' => $activity['actor'], 'author' => $activity['author']]);
+                                       $item['isGroup']    = true;
+                                       $item['owner-link'] = $audience;
+                                       $item['owner-id']   = Contact::getIdForURL($audience);
+                               }
+                       }
+               }
+
                $item['uri'] = $activity['id'];
 
                if (empty($activity['published']) || empty($activity['updated'])) {
@@ -1060,9 +1072,9 @@ class Processor
                        }
 
                        if ($item['isGroup'] ?? false) {
-                               $item['contact-id'] = Contact::getIdForURL($activity['actor'], $receiver);
+                               $item['contact-id'] = Contact::getIdForURL($item['owner-link'], $receiver);
                        } else {
-                               $item['contact-id'] = Contact::getIdForURL($activity['author'], $receiver);
+                               $item['contact-id'] = Contact::getIdForURL($item['author-link'], $receiver);
                        }
 
                        if (($receiver != 0) && empty($item['contact-id'])) {