]> git.mxchange.org Git - friendica.git/commitdiff
Add tombstone object for AP response on deleted profile
authorHypolite Petovan <hypolite@mrpetovan.com>
Mon, 1 Apr 2019 07:15:41 +0000 (03:15 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Mon, 1 Apr 2019 07:15:41 +0000 (03:15 -0400)
- Responds with 404 status code with all other non-success cases

src/Module/Profile.php

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