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