[PLUGIN][ActivityPub][Model][Activity] toJson: When in activity context, use object's context if available

This commit is contained in:
Diogo Peralta Cordeiro 2022-03-19 22:20:17 +00:00
parent 23e88b30a6
commit 6955872e05
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0

View File

@ -170,8 +170,8 @@ class Activity extends Model
'actor' => $object->getActor()->getUri(Router::ABSOLUTE_URL), 'actor' => $object->getActor()->getUri(Router::ABSOLUTE_URL),
]; ];
$attr['to'] = []; $attr['to'] = ['https://www.w3.org/ns/activitystreams#Public'];
$attr['cc'] = ['https://www.w3.org/ns/activitystreams#Public']; $attr['cc'] = [];
foreach ($object->getAttentionTargets() as $target) { foreach ($object->getAttentionTargets() as $target) {
$attr['cc'][] = $target->getUri(); $attr['cc'][] = $target->getUri();
} }
@ -191,6 +191,7 @@ class Activity extends Model
} }
if (!\is_string($attr['object'])) { if (!\is_string($attr['object'])) {
$attr['@context'] = $attr['object']->get('@context');
$attr['object']->set('@context', null); $attr['object']->set('@context', null);
} }
$type = self::jsonToType($attr); $type = self::jsonToType($attr);