[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

@@ -100,7 +100,7 @@ class Activitypub_notice
} else { // Note
$item = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => self::getUri($notice),
'id' => self::note_uri($notice->getID()),
'type' => 'Note',
'published' => str_replace(' ', 'T', $notice->getCreated()) . 'Z',
'url' => $notice->getUrl(),
@@ -310,6 +310,7 @@ class Activitypub_notice
* @throws InvalidUrlException
* @throws Exception
* @author Bruno Casteleiro <brunoccast@fc.up.pt>
* @see note_uri when it's not a generic activity but a object type note
*/
public static function getUri(Notice $notice): string
{
@@ -320,6 +321,19 @@ class Activitypub_notice
}
}
/**
* Use this if your Notice is in fact a note
*
* @param int $id
* @return string it's uri
* @author Diogo Cordeiro <diogo@fc.up.pt>
* @see getUri for every other activity that aren't objects of a certain type like note
*/
public static function note_uri(int $id): string
{
return common_root_url() . 'object/note/' . $id;
}
/**
* Extract note policy type from note targets.
*