]> git.mxchange.org Git - friendica.git/commitdiff
Set the group as owner for "group only" postings
authorMichael <heluecht@pirati.ca>
Sun, 25 Jun 2023 22:14:35 +0000 (22:14 +0000)
committerMichael <heluecht@pirati.ca>
Sun, 25 Jun 2023 22:14:35 +0000 (22:14 +0000)
src/Content/Item.php
src/Protocol/ActivityPub/Processor.php

index 517d537d407299aac8213cc577ec92a0e3dea243..bd3c6d774b8d55abe702604c3c7176f4a75a7c16 100644 (file)
@@ -537,6 +537,14 @@ class Item
                        $item['private'] = $private_group ? ItemModel::PRIVATE : ItemModel::UNLISTED;
 
                        if ($only_to_group) {
+                               $cdata = Contact::getPublicAndUserContactID($group_contact['id'], $item['uid']);
+                               if (!empty($cdata['user'])) {
+                                       $item['owner-id'] = $cdata['user'];
+                                       unset($item['owner-link']);
+                                       unset($item['owner-name']);
+                                       unset($item['owner-avatar']);
+                               }
+       
                                $item['postopts'] = '';
                        }
 
index 9758e4fd48b9b9ffb6697d1eac1e14b728566c16..d8cd271ea4231a58bbcafff2facd2516d1d29935 100644 (file)
@@ -421,7 +421,7 @@ class Processor
                        if ($activity['thread-completion'] != $item['owner-id']) {
                                $actor = Contact::getById($activity['thread-completion'], ['url']);
                                $item['causer-link'] = $actor['url'];
-                               $item['causer-id'] = $activity['thread-completion'];
+                               $item['causer-id']   = $activity['thread-completion'];
                                Logger::info('Use inherited actor as causer.', ['id' => $item['owner-id'], 'activity' => $activity['thread-completion'], 'owner' => $item['owner-link'], 'actor' => $actor['url']]);
                        } else {
                                // Store the original actor in the "causer" fields to enable the check for ignored or blocked contacts
@@ -431,7 +431,7 @@ class Processor
                        }
 
                        $item['owner-link'] = $item['author-link'];
-                       $item['owner-id'] = $item['author-id'];
+                       $item['owner-id']   = $item['author-id'];
                }
 
                if (!$item['isGroup'] && !empty($activity['receiver_urls']['as:audience'])) {
@@ -440,7 +440,8 @@ class Processor
                                if (($actor['type'] ?? 'Person') == 'Group') {
                                        Logger::debug('Group post detected via audience.', ['audience' => $audience, 'actor' => $activity['actor'], 'author' => $activity['author']]);
                                        $item['isGroup']    = true;
-                                       $item['group-link'] = $audience;
+                                       $item['group-link'] = $item['owner-link'] = $audience;
+                                       $item['owner-id']   = Contact::getIdForURL($audience);
                                }
                        }
                } else {
@@ -457,13 +458,13 @@ class Processor
 
                if (!$item['isGroup'] && (($causer['type'] ?? 'Person') == 'Group')) {
                        Logger::debug('Group post detected via causer.', ['actor' => $activity['actor'], 'author' => $activity['author'], 'causer' => $item['causer-link']]);
-                       $item['isGroup'] = true;
+                       $item['isGroup']    = true;
                        $item['group-link'] = $item['causer-link'];
                }
 
                if (!empty($item['group-link']) && empty($item['causer-link'])) {
                        $item['causer-link'] = $item['group-link'];
-                       $item['causer-id'] = Contact::getIdForURL($item['causer-link']);
+                       $item['causer-id']   = Contact::getIdForURL($item['causer-link']);
                }
 
                $item['uri'] = $activity['id'];