[PLUGIN][ActivityPub] Support tags in notes

This commit is contained in:
2021-12-24 21:02:02 +00:00
parent 36483a6ecd
commit 9d0b39e680
4 changed files with 31 additions and 16 deletions

View File

@@ -241,18 +241,18 @@ class Note extends Model
}
$attr = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'type' => 'Note',
'id' => $object->getUrl(),
'published' => $object->getCreated()->format(DateTimeInterface::RFC3339),
'attributedTo' => $object->getActor()->getUri(Router::ABSOLUTE_URL),
'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address
'cc' => ['https://www.w3.org/ns/activitystreams#Public'],
'content' => $object->getRendered(),
'attachment' => [],
'tag' => [],
'conversation' => $object->getConversationUri(),
'directMessage' => false, // TODO: implement proper scope address
'@context' => 'https://www.w3.org/ns/activitystreams',
'type' => 'Note',
'id' => $object->getUrl(),
'published' => $object->getCreated()->format(DateTimeInterface::RFC3339),
'attributedTo' => $object->getActor()->getUri(Router::ABSOLUTE_URL),
'to' => ['https://www.w3.org/ns/activitystreams#Public'], // TODO: implement proper scope address
'cc' => ['https://www.w3.org/ns/activitystreams#Public'],
'content' => $object->getRendered(),
'attachment' => [],
'tag' => [],
'inConversation' => $object->getConversationUri(),
'directMessage' => false, // TODO: implement proper scope address
];
// Mentions
@@ -265,6 +265,15 @@ class Note extends Model
$attr['cc'][] = $href;
}
// Hashtags
foreach ($object->getTags() as $hashtag) {
$attr['tag'][] = [
'type' => 'Hashtag',
'href' => $hashtag->getUrl(type: Router::ABSOLUTE_URL),
'name' => "#{$hashtag->getTag()}",
];
}
// Attachments
foreach ($object->getAttachments() as $attachment) {
$attr['attachment'][] = [