From 8d5876d5f26e7e7c19b73e1d6990e6921bf2ef73 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 25 Jun 2023 22:14:35 +0000 Subject: [PATCH] Set the group as owner for "group only" postings --- src/Content/Item.php | 8 ++++++++ src/Protocol/ActivityPub/Processor.php | 11 ++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Content/Item.php b/src/Content/Item.php index 517d537d40..bd3c6d774b 100644 --- a/src/Content/Item.php +++ b/src/Content/Item.php @@ -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'] = ''; } diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index 9758e4fd48..d8cd271ea4 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -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']; -- 2.39.5