[ActivityPub][Postman] Fill To and CC with mentions

This commit is contained in:
Diogo Peralta Cordeiro 2021-12-21 14:13:12 +00:00
parent 48b2c8c04e
commit 1865d2b41e
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 6 additions and 1 deletions

View File

@ -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]);

View File

@ -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