From e911302fe94b45fe76a1c27d00d6a24a010f5e0e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Mon, 1 Apr 2019 03:15:41 -0400 Subject: [PATCH] Add tombstone object for AP response on deleted profile - Responds with 404 status code with all other non-success cases --- src/Module/Profile.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Module/Profile.php b/src/Module/Profile.php index e43554a1ce..a9a1fe6d09 100644 --- a/src/Module/Profile.php +++ b/src/Module/Profile.php @@ -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); } } } -- 2.39.5