[ActivityPub] Fix note URIs

This commit is contained in:
Diogo Cordeiro
2020-08-29 23:51:46 +01:00
parent c8e9cbdbb8
commit 8c20ed0c89
6 changed files with 32 additions and 8 deletions

View File

@@ -97,8 +97,8 @@ class ActivityPubPlugin extends Plugin
// Look for a local notice (unfortunately GNU social doesn't
// provide this functionality natively)
try {
$candidate = Notice::getByID((int)substr($url, (strlen(common_local_url('apNotice', ['id' => 0]))-1)));
if (common_local_url('apNotice', ['id' => $candidate->getID()]) === $url) { // Sanity check
$candidate = Notice::getByID((int)substr($url, (strlen(Activitypub_notice::note_uri(0))-1)));
if (Activitypub_notice::note_uri($candidate->getID()) === $url) { // Sanity check
return $candidate;
} else {
common_debug('ActivityPubPlugin Notice Grabber: '.$candidate->getUrl(). ' is different of '.$url);
@@ -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'],