From f6b9f8d476fce2709fada3c6266070d9f5ca7fd4 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 26 Jun 2023 19:37:20 +0000 Subject: [PATCH] Added group detection for via exclusive mentions --- src/Protocol/ActivityPub/Processor.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Protocol/ActivityPub/Processor.php b/src/Protocol/ActivityPub/Processor.php index d8cd271ea..7ba5266b4 100644 --- a/src/Protocol/ActivityPub/Processor.php +++ b/src/Protocol/ActivityPub/Processor.php @@ -442,6 +442,7 @@ class Processor $item['isGroup'] = true; $item['group-link'] = $item['owner-link'] = $audience; $item['owner-id'] = Contact::getIdForURL($audience); + break; } } } else { @@ -902,6 +903,19 @@ class Processor $item['raw-body'] = $item['body'] = $content; } + if (!empty($item['author-id']) && ($item['author-id'] == $item['owner-id'])) { + foreach (Tag::getFromBody($item['body'], Tag::TAG_CHARACTER[Tag::EXCLUSIVE_MENTION]) as $tag) { + $actor = APContact::getByURL($tag[2], false); + if (($actor['type'] ?? 'Person') == 'Group') { + Logger::debug('Group post detected via exclusive mention.', ['mention' => $actor['url'], 'actor' => $activity['actor'], 'author' => $activity['author']]); + $item['isGroup'] = true; + $item['group-link'] = $item['owner-link'] = $actor['url']; + $item['owner-id'] = Contact::getIdForURL($actor['url']); + break; + } + } + } + self::storeFromBody($item); self::storeTags($item['uri-id'], $activity['tags']);