[ActivityPub] Fix note URIs

Esse commit está contido em:
Diogo Cordeiro
2020-08-29 23:51:46 +01:00
commit f0a09e7216
6 arquivos alterados com 15 adições e 5 exclusões
+6
Ver Arquivo
@@ -196,6 +196,12 @@ class ActivityPubPlugin extends Plugin
$acceptHeaders
);
$m->connect(
'object/note/:id',
['action' => 'apNotice'],
['id' => '[0-9]+'],
);
$m->connect(
'user/:id/liked.json',
['action' => 'apActorLiked'],
@@ -124,6 +124,7 @@ class apActorOutboxAction extends ManagedAction
if ($note->object_type == 'http://activitystrea.ms/schema/1.0/note') {
$notices[] = Activitypub_create::create_to_array(
$note->getProfile()->getUri(),
common_local_url('apNotice', ['id' => $note->getID()]),
Activitypub_notice::notice_to_array($note)
);
}
@@ -40,16 +40,17 @@ class Activitypub_create
* Generates an ActivityPub representation of a Create
*
* @param string $actor
* @param array $object
* @param string $uri
* @param mixed $object
* @param bool $directMessage whether it is a private Create activity or not
* @return array pretty array to be used in a response
* @author Diogo Cordeiro <diogo@fc.up.pt>
*/
public static function create_to_array(string $actor, array $object, bool $directMessage = false): array
public static function create_to_array(string $actor, string $uri, $object, bool $directMessage = false): array
{
$res = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $object['id'] . '#create',
'id' => $uri,
'type' => 'Create',
'directMessage' => $directMessage,
'to' => $object['to'],
@@ -100,7 +100,7 @@ class Activitypub_notice
} else { // Note
$item = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => self::getUri($notice),
'id' => common_root_url() . 'object/note/'.$notice->getID(),
'type' => 'Note',
'published' => str_replace(' ', 'T', $notice->getCreated()) . 'Z',
'url' => $notice->getUrl(),
@@ -48,7 +48,7 @@ class Activitypub_tombstone
$dead = Deleted_notice::getByID($id);
$res = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => Activitypub_notice::getUri($id),
'id' => common_root_url() . 'object/note/' . $id,
'type' => 'Tombstone',
'created' => str_replace(' ', 'T', $dead->act_created) . 'Z',
'deleted' => str_replace(' ', 'T', $dead->created) . 'Z'
+2
Ver Arquivo
@@ -290,6 +290,7 @@ class Activitypub_postman
{
$data = Activitypub_create::create_to_array(
$this->actor_uri,
common_local_url('apNotice', ['id' => $notice->getID()]),
Activitypub_notice::notice_to_array($notice)
);
$data = json_encode($data, JSON_UNESCAPED_SLASHES);
@@ -321,6 +322,7 @@ class Activitypub_postman
{
$data = Activitypub_create::create_to_array(
$this->actor_uri,
common_local_url('apNotice', ['id' => $message->getID()]),
Activitypub_message::message_to_array($message),
true
);