Browse Source

Add tombstone object for AP response on deleted profile

- Responds with 404 status code with all other non-success cases
pull/6957/head
Hypolite Petovan 2 years ago
parent
commit
e911302fe9
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      src/Module/Profile.php

+ 16
- 3
src/Module/Profile.php 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);
}
}
}


Loading…
Cancel
Save