From c3cdde0873aa5c16676fc325cbe520e822bf9669 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Sat, 29 Aug 2020 22:18:00 +0100 Subject: [PATCH] [ActivityPub] Tombstones now have datetimes --- plugins/ActivityPub/actions/apnotice.php | 2 +- .../ActivityPub/lib/models/Activitypub_message.php | 2 +- plugins/ActivityPub/lib/models/Activitypub_notice.php | 2 +- .../ActivityPub/lib/models/Activitypub_tombstone.php | 11 +++++++---- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/plugins/ActivityPub/actions/apnotice.php b/plugins/ActivityPub/actions/apnotice.php index 9b88c18ae6..3d91b7abd6 100644 --- a/plugins/ActivityPub/actions/apnotice.php +++ b/plugins/ActivityPub/actions/apnotice.php @@ -79,7 +79,7 @@ class apNoticeAction extends ManagedAction $this->notice = $this->getNotice(); } catch (ClientException $e) { //ActivityPubReturn::error('Activity deleted.', 410); - ActivityPubReturn::answer(Activitypub_tombstone::tombstone_to_array(common_local_url('apNotice', ['id' => $this->notice_id])), 410); + ActivityPubReturn::answer(Activitypub_tombstone::tombstone_to_array($this->notice_id), 410); } $this->target = $this->notice; diff --git a/plugins/ActivityPub/lib/models/Activitypub_message.php b/plugins/ActivityPub/lib/models/Activitypub_message.php index e7d9bdceea..adbbfa5d4c 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_message.php +++ b/plugins/ActivityPub/lib/models/Activitypub_message.php @@ -47,7 +47,7 @@ class Activitypub_message $tags = []; foreach ($message->getTags() as $tag) { - if ($tag != "") { // Hacky workaround to avoid stupid outputs + if ($tag != '') { // Hacky workaround to avoid stupid outputs $tags[] = Activitypub_tag::tag_to_array($tag); } } diff --git a/plugins/ActivityPub/lib/models/Activitypub_notice.php b/plugins/ActivityPub/lib/models/Activitypub_notice.php index 96431f30ca..486a3b182f 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_notice.php +++ b/plugins/ActivityPub/lib/models/Activitypub_notice.php @@ -85,7 +85,7 @@ class Activitypub_notice 'id' => self::getUri($notice), 'type' => 'Delete', // XXX: A bit of ugly code here - 'object' => array_merge(Activitypub_tombstone::tombstone_to_array(common_local_url('apNotice', ['id' => (int)substr(explode(':', $notice->getUri())[2],9)])), ['deleted' => str_replace(' ', 'T', $notice->getCreated()) . 'Z']), + 'object' => array_merge(Activitypub_tombstone::tombstone_to_array((int)substr(explode(':', $notice->getUri())[2],9)), ['deleted' => str_replace(' ', 'T', $notice->getCreated()) . 'Z']), 'url' => $notice->getUrl(), 'actor' => $profile->getUri(), 'to' => $to, diff --git a/plugins/ActivityPub/lib/models/Activitypub_tombstone.php b/plugins/ActivityPub/lib/models/Activitypub_tombstone.php index 39f9176081..aa2be34bb0 100644 --- a/plugins/ActivityPub/lib/models/Activitypub_tombstone.php +++ b/plugins/ActivityPub/lib/models/Activitypub_tombstone.php @@ -39,16 +39,19 @@ class Activitypub_tombstone /** * Generates an ActivityPub representation of a Tombstone * - * @param string $id Activity id + * @param int $id Activity id * @return array pretty array to be used in a response * @author Diogo Cordeiro */ - public static function tombstone_to_array(string $id): array + public static function tombstone_to_array(int $id): array { + $dead = Deleted_notice::getByID($id); $res = [ '@context' => 'https://www.w3.org/ns/activitystreams', - 'id' => $id, - 'type' => 'Tombstone' + 'id' => Activitypub_notice::getUri($id), + 'type' => 'Tombstone', + 'created' => str_replace(' ', 'T', $dead->act_created) . 'Z', + 'deleted' => str_replace(' ', 'T', $dead->created) . 'Z' ]; return $res; }