Make notes great again!

This commit is contained in:
Diogo Cordeiro 2018-08-06 08:35:48 +01:00
parent fcbdf6aef2
commit ca8867c1c0
2 changed files with 5 additions and 4 deletions

View File

@ -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]+']
);

View File

@ -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();
}