From ca8867c1c0f87ac1d25216aabd81c2d442c3e086 Mon Sep 17 00:00:00 2001 From: Diogo Cordeiro Date: Mon, 6 Aug 2018 08:35:48 +0100 Subject: [PATCH] Make notes great again! --- ActivityPubPlugin.php | 7 ++++--- classes/Activitypub_notice.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ActivityPubPlugin.php b/ActivityPubPlugin.php index 8ab5ec7..c234e70 100755 --- a/ActivityPubPlugin.php +++ b/ActivityPubPlugin.php @@ -106,8 +106,8 @@ class ActivityPubPlugin extends Plugin // Look for a local notice (unfortunately GNU Social doesn't // provide this functionality natively) try { - $candidate = Notice::getByID(intval(substr($url, strlen(common_local_url('shownotice', ['notice' => '']))))); - if ($candidate->getUrl() == $url) { // Sanity check + $candidate = Notice::getByID(intval(substr($url, (strlen(common_local_url('apNotice', ['id' => 0]))-1)))); + if (common_local_url('apNotice', ['id' => $candidate->getID()]) === $url) { // Sanity check return $candidate; } else { common_debug('ActivityPubPlugin Notice Grabber: '.$candidate->getUrl(). ' is different of '.$url); @@ -153,8 +153,9 @@ class ActivityPubPlugin extends Plugin ); } + // No .json here for convenience purposes on Notice grabber $m->connect( - 'note/:id.json', + 'note/:id', ['action' => 'apNotice'], ['id' => '[0-9]+'] ); diff --git a/classes/Activitypub_notice.php b/classes/Activitypub_notice.php index 0f515cb..864fafc 100755 --- a/classes/Activitypub_notice.php +++ b/classes/Activitypub_notice.php @@ -90,7 +90,7 @@ class Activitypub_notice extends Managed_DataObject // Is this a reply? if (!empty($notice->reply_to)) { - $item['inReplyTo'] = Notice::getById($notice->reply_to)->getUrl(); + $item['inReplyTo'] = common_local_url('apNotice', ['id' => $notice->getID()]); $item['inReplyToAtomUri'] = Notice::getById($notice->reply_to)->getUrl(); }