Add tombstone object for AP response on deleted profile

- Responds with 404 status code with all other non-success cases
This commit is contained in:
Hypolite Petovan 2019-04-01 03:15:41 -04:00
parent 9f49ce8857
commit e911302fe9

View file

@ -54,15 +54,28 @@ class Profile extends BaseModule
{
if (ActivityPub::isRequest()) {
$user = DBA::selectFirst('user', ['uid'], ['nickname' => self::$which]);
$data = [];
if (DBA::isResult($user)) {
$data = ActivityPub\Transmitter::getProfile($user['uid']);
}
if (!empty($data)) {
System::jsonExit($data, 'application/activity+json');
} elseif (DBA::exists('userd', ['username' => self::$which])) {
// Known deleted user
System::httpExit(410);
$data = [
'@context' => ActivityPub::CONTEXT,
'id' => System::baseUrl() . '/profile/' . self::$which,
'type' => 'Tombstone',
'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
'updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
'deleted' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
];
System::jsonError(410, $data);
} else {
// Unknown user
System::httpExit(404);
// Any other case (unknown, blocked, unverified, expired, no profile, no self contact)
System::jsonError(404, $data);
}
}
}