[ActivityPub] Tombstones now have datetimes

This commit is contained in:
Diogo Cordeiro 2020-08-29 22:18:00 +01:00 committed by Diogo Peralta Cordeiro
parent cb78573f59
commit c3cdde0873
4 changed files with 10 additions and 7 deletions

View File

@ -79,7 +79,7 @@ class apNoticeAction extends ManagedAction
$this->notice = $this->getNotice();
} catch (ClientException $e) {
//ActivityPubReturn::error('Activity deleted.', 410);
ActivityPubReturn::answer(Activitypub_tombstone::tombstone_to_array(common_local_url('apNotice', ['id' => $this->notice_id])), 410);
ActivityPubReturn::answer(Activitypub_tombstone::tombstone_to_array($this->notice_id), 410);
}
$this->target = $this->notice;

View File

@ -47,7 +47,7 @@ class Activitypub_message
$tags = [];
foreach ($message->getTags() as $tag) {
if ($tag != "") { // Hacky workaround to avoid stupid outputs
if ($tag != '') { // Hacky workaround to avoid stupid outputs
$tags[] = Activitypub_tag::tag_to_array($tag);
}
}

View File

@ -85,7 +85,7 @@ class Activitypub_notice
'id' => self::getUri($notice),
'type' => 'Delete',
// XXX: A bit of ugly code here
'object' => array_merge(Activitypub_tombstone::tombstone_to_array(common_local_url('apNotice', ['id' => (int)substr(explode(':', $notice->getUri())[2],9)])), ['deleted' => str_replace(' ', 'T', $notice->getCreated()) . 'Z']),
'object' => array_merge(Activitypub_tombstone::tombstone_to_array((int)substr(explode(':', $notice->getUri())[2],9)), ['deleted' => str_replace(' ', 'T', $notice->getCreated()) . 'Z']),
'url' => $notice->getUrl(),
'actor' => $profile->getUri(),
'to' => $to,

View File

@ -39,16 +39,19 @@ class Activitypub_tombstone
/**
* Generates an ActivityPub representation of a Tombstone
*
* @param string $id Activity id
* @param int $id Activity id
* @return array pretty array to be used in a response
* @author Diogo Cordeiro <diogo@fc.up.pt>
*/
public static function tombstone_to_array(string $id): array
public static function tombstone_to_array(int $id): array
{
$dead = Deleted_notice::getByID($id);
$res = [
'@context' => 'https://www.w3.org/ns/activitystreams',
'id' => $id,
'type' => 'Tombstone'
'id' => Activitypub_notice::getUri($id),
'type' => 'Tombstone',
'created' => str_replace(' ', 'T', $dead->act_created) . 'Z',
'deleted' => str_replace(' ', 'T', $dead->created) . 'Z'
];
return $res;
}