[ActivityPub][Model][Activity] Translate including objects

This commit is contained in:
2021-12-01 20:53:32 +00:00
parent e7ee558f4a
commit 6f543ccc06
6 changed files with 36 additions and 40 deletions

View File

@@ -17,7 +17,7 @@ use Plugin\ActivityPub\Entity\ActivitypubActivity;
abstract class AS2ToEntity
{
public static function activity_stream_two_verb_to_gs_verb($verb)
public static function activity_stream_two_verb_to_gs_verb(string $verb): string
{
return match ($verb) {
'Create' => 'create',
@@ -25,7 +25,7 @@ abstract class AS2ToEntity
};
}
public static function activity_stream_two_object_type_to_gs_table($object)
public static function activity_stream_two_object_type_to_gs_table(string $object): string
{
return match ($object) {
'Note' => 'note',

View File

@@ -32,9 +32,9 @@ class ActivityToType
'id' => Router::url('activity_view', ['id' => $activity->getId()], Router::ABSOLUTE_URL),
'published' => $activity->getCreated()->format(DateTimeInterface::RFC3339),
'actor' => $activity->getActor()->getUri(Router::ABSOLUTE_URL),
//'to' => $to,
//'cc' => $cc,
'object' => $activity->getObject()->getUrl(),
'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address
'cc' => ['https://www.w3.org/ns/activitystreams#Public'],
'object' => EntityToType::translate($activity->getObject()),
];
return Type::create($attr);
}

View File

@@ -22,9 +22,9 @@ class NoteToType
'id' => Router::url('note_view', ['id' => $note->getId()], Router::ABSOLUTE_URL),
'published' => $note->getCreated()->format(DateTimeInterface::RFC3339),
'attributedTo' => $note->getActor()->getUri(Router::ABSOLUTE_URL),
//'to' => $to,
//'cc' => $cc,
'content' => json_encode($note->getRendered()),
'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address
'cc' => ['https://www.w3.org/ns/activitystreams#Public'],
'content' => $note->getRendered(),
//'tag' => $tags
];
return Type::create(type: 'Note', attributes: $attr);