diff --git a/plugins/ActivityPub/ActivityPubPlugin.php b/plugins/ActivityPub/ActivityPubPlugin.php index 610f1e755c..eb3ede8a8b 100644 --- a/plugins/ActivityPub/ActivityPubPlugin.php +++ b/plugins/ActivityPub/ActivityPubPlugin.php @@ -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'], diff --git a/plugins/ActivityPub/actions/apactoroutbox.php b/plugins/ActivityPub/actions/apactoroutbox.php index 3762e80a72..b80ec568fe 100644 --- a/plugins/ActivityPub/actions/apactoroutbox.php +++ b/plugins/ActivityPub/actions/apactoroutbox.php @@ -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) ); } diff --git a/plugins/ActivityPub/lib/models/Activitypub_create.php b/plugins/ActivityPub/lib/models/Activitypub_create.php index 0a6c0e50a6..569569ffee 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_create.php +++ b/plugins/ActivityPub/lib/models/Activitypub_create.php @@ -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 */ - 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'], diff --git a/plugins/ActivityPub/lib/models/Activitypub_notice.php b/plugins/ActivityPub/lib/models/Activitypub_notice.php index 486a3b182f..04e3c716c9 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_notice.php +++ b/plugins/ActivityPub/lib/models/Activitypub_notice.php @@ -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(), diff --git a/plugins/ActivityPub/lib/models/Activitypub_tombstone.php b/plugins/ActivityPub/lib/models/Activitypub_tombstone.php index aa2be34bb0..3b647d14e6 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_tombstone.php +++ b/plugins/ActivityPub/lib/models/Activitypub_tombstone.php @@ -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' diff --git a/plugins/ActivityPub/lib/postman.php b/plugins/ActivityPub/lib/postman.php index 8818c6c23b..5d7cdeeeeb 100644 --- a/plugins/ActivityPub/lib/postman.php +++ b/plugins/ActivityPub/lib/postman.php @@ -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 );