Add location to notices (closes #44)
This commit is contained in:
parent
edb3633bcd
commit
20738f48cd
@ -108,9 +108,10 @@ class apActorLikedAction extends ManagedAction
|
|||||||
*/
|
*/
|
||||||
protected function pretty_fave($fave_object)
|
protected function pretty_fave($fave_object)
|
||||||
{
|
{
|
||||||
$res = array("uri" => $fave_object->uri,
|
$res = [
|
||||||
"created" => $fave_object->created,
|
'created' => $fave_object->created,
|
||||||
"object" => Activitypub_notice::notice_to_array(Notice::getByID($fave_object->notice_id)));
|
'object' => Activitypub_notice::notice_to_array(Notice::getByID($fave_object->notice_id))
|
||||||
|
];
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,11 @@ foreach ($to_profiles as $tp) {
|
|||||||
$act->context->attention[ActivityPubPlugin::actor_uri($tp)] = "http://activitystrea.ms/schema/1.0/person";
|
$act->context->attention[ActivityPubPlugin::actor_uri($tp)] = "http://activitystrea.ms/schema/1.0/person";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add location if that is set
|
||||||
|
if (isset ($data->object->latitude, $data->object->longitude)) {
|
||||||
|
$act->context->location = Location::fromLatLon($data->object->latitude, $data->object->longitude);
|
||||||
|
}
|
||||||
|
|
||||||
// Reject notice if it is too long (without the HTML)
|
// Reject notice if it is too long (without the HTML)
|
||||||
// This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction
|
// This is done after MediaFile::fromUpload etc. just to act the same as the ApiStatusesUpdateAction
|
||||||
if (Notice::contentTooLong($content)) {
|
if (Notice::contentTooLong($content)) {
|
||||||
|
@ -71,21 +71,31 @@ class Activitypub_notice extends Managed_DataObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
$item = [
|
$item = [
|
||||||
'id' => $notice->getUrl(),
|
'context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
'type' => 'Note',
|
'id' => $notice->getUrl(),
|
||||||
'inReplyTo' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
'type' => 'Note',
|
||||||
'published' => $notice->getCreated(),
|
'inReplyTo' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
||||||
'url' => $notice->getUrl(),
|
'published' => $notice->getCreated(),
|
||||||
'atributedTo' => ActivityPubPlugin::actor_uri($profile),
|
'url' => $notice->getUrl(),
|
||||||
'to' => $to,
|
'atributedTo' => ActivityPubPlugin::actor_uri($profile),
|
||||||
'atomUri' => $notice->getUrl(),
|
'to' => $to,
|
||||||
'inReplyToAtomUri' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
'atomUri' => $notice->getUrl(),
|
||||||
'conversation' => $notice->getConversationUrl(),
|
'inReplyToAtomUri' => empty($notice->reply_to) ? null : Notice::getById($notice->reply_to)->getUrl(),
|
||||||
'content' => $notice->getContent(),
|
'conversation' => $notice->getConversationUrl(),
|
||||||
'is_local' => $notice->isLocal(),
|
'content' => $notice->getContent(),
|
||||||
'attachment' => $attachments,
|
'is_local' => $notice->isLocal(),
|
||||||
'tag' => $tags
|
'attachment' => $attachments,
|
||||||
];
|
'tag' => $tags
|
||||||
|
];
|
||||||
|
|
||||||
|
// Do we have a location for this notice?
|
||||||
|
try {
|
||||||
|
$location = Notice_location::locFromStored($notice);
|
||||||
|
$item['latitude'] = $location->lat;
|
||||||
|
$item['longitude'] = $location->lon;
|
||||||
|
} catch (Exception $ex) {
|
||||||
|
// Apparently no.
|
||||||
|
}
|
||||||
|
|
||||||
return $item;
|
return $item;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user