Improved Notice Entity

This commit is contained in:
Diogo Cordeiro 2018-07-09 20:07:35 +01:00
parent 7d773729b9
commit 80b9d1873c

View File

@ -44,28 +44,30 @@ class Activitypub_notice extends Managed_DataObject
$tags = []; $tags = [];
foreach ($notice->getTags () as $tag) foreach ($notice->getTags () as $tag)
{ {
$tags[] = Activitypub_tag::tagNameToObject ($tag); if ($tag != "") { // Hacky workaround to avoid stupid outputs
$tags[] = Activitypub_tag::tagNameToObject ($tag);
}
} }
// todo: fix timestamp formats $to = array ();
$item = [ foreach ($notice->getAttentionProfileIDs () as $to_id) {
'id' => $notice->getUrl(), $to[] = Profile::getById ($to_id)->getUri ();
'type' => 'Notice', // TODO: handle other types }
'actor' => $notice->getProfile()->getUrl(), if (!is_null ($to)) {
$to = array("https://www.w3.org/ns/activitystreams#Public");
}
$item = [
'id' => $notice->getUrl (),
'type' => 'Notice',
'actor' => $notice->getProfile ()->getUrl (),
'published' => $notice->getCreated (), 'published' => $notice->getCreated (),
'to' => [ 'to' => $to,
// TODO: handle proper scope 'content' => $notice->getContent (),
'https://www.w3.org/ns/activitystreams#Public' 'url' => $notice->getUrl (),
], 'reply_to' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl (),
'cc' => [ 'is_local' => $notice->isLocal (),
// TODO: add cc's 'conversation' => intval ($notice->conversation),
"{$notice->getProfile()->getUrl()}/subscribers",
],
'content' => $notice->getContent(),
'url' => $notice->getUrl(),
'reply_to' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
'is_local' => $notice->isLocal(),
'conversation' => intval($notice->conversation),
'attachment' => $attachments, 'attachment' => $attachments,
'tag' => $tags 'tag' => $tags
]; ];