[ActivityPub] Re-implement Delete Actor

This commit is contained in:
2021-02-21 14:59:36 +00:00
parent 4f0ddc85d3
commit b1e6b00545
3 changed files with 26 additions and 13 deletions

View File

@@ -27,7 +27,7 @@
defined('GNUSOCIAL') || die();
/**
* ActivityPub error representation
* ActivityPub delete representation
*
* @category Plugin
* @package GNUsocial
@@ -37,15 +37,29 @@ defined('GNUSOCIAL') || die();
class Activitypub_delete
{
/**
* Generates an ActivityPub representation of a Delete
* Generates an ActivityStreams 2.0 representation of a Delete
*
* @param Notice $notice
* @param Notice $object
* @return array pretty array to be used in a response
* @author Diogo Cordeiro <diogo@fc.up.pt>
*/
public static function delete_to_array(Notice $notice): array
public static function delete_to_array($object): array
{
return Activitypub_notice::notice_to_array($notice);
if ($object instanceof Notice) {
return Activitypub_notice::notice_to_array($object);
} else if ($object instanceof Profile) {
$actor_uri = $object->getUri();
return [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $actor_uri . '#delete',
'type' => 'Delete',
'to' => ['https://www.w3.org/ns/activitystreams#Public'],
'actor' => $actor_uri,
'object' => $object
];
} else {
throw new InvalidArgumentException();
}
}
/**