From 1865d2b41e71aacc774cf0e654b628b873d9f863 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Tue, 21 Dec 2021 14:13:12 +0000 Subject: [PATCH] [ActivityPub][Postman] Fill To and CC with mentions --- plugins/ActivityPub/Util/Model/Activity.php | 5 ++++- plugins/ActivityPub/Util/Model/Note.php | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/ActivityPub/Util/Model/Activity.php b/plugins/ActivityPub/Util/Model/Activity.php index f5ce715a94..a31dc254a6 100644 --- a/plugins/ActivityPub/Util/Model/Activity.php +++ b/plugins/ActivityPub/Util/Model/Activity.php @@ -170,7 +170,10 @@ class Activity extends Model 'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address 'cc' => ['https://www.w3.org/ns/activitystreams#Public'], ]; - $attr['object'] = $attr['type'] === 'Create' ? self::jsonToType(Model::toJson($object->getObject())) : ActivityPub::getUriByObject($object->getObject()); + $attr['object'] = ($attr['type'] === 'Create') ? self::jsonToType(Model::toJson($object->getObject())) : ActivityPub::getUriByObject($object->getObject()); + + $attr['to'] = array_unique(array_merge($attr['to'], $attr['object']->get('to'))); + $attr['cc'] = array_unique(array_merge($attr['cc'], $attr['object']->get('cc'))); $type = self::jsonToType($attr); Event::handle('ActivityPubAddActivityStreamsTwoData', [$type->get('type'), &$type]); diff --git a/plugins/ActivityPub/Util/Model/Note.php b/plugins/ActivityPub/Util/Model/Note.php index 413fab7365..874871fa4b 100644 --- a/plugins/ActivityPub/Util/Model/Note.php +++ b/plugins/ActivityPub/Util/Model/Note.php @@ -233,6 +233,7 @@ class Note extends Model 'content' => $object->getRendered(), 'attachment' => [], 'tag' => [], + 'directMessage' => false, // // TODO: implement proper scope address ]; // Mentions @@ -242,6 +243,7 @@ class Note extends Model 'href' => ($href = $mention->getUri()), 'name' => '@'.$mention->getNickname().'@'.parse_url($href, PHP_URL_HOST) ]; + $attr['cc'][] = $href; } // Attachments