Merge pull request #6957 from MrPetovan/bug/6943-add-tombstone
authorMichael Vogel <icarus@dabo.de>
Thu, 4 Apr 2019 20:27:49 +0000 (22:27 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Apr 2019 20:27:49 +0000 (22:27 +0200)
Send AP Tombstone activity on deleted profiles

CHANGELOG
src/Module/Profile.php
src/Protocol/ActivityPub/Transmitter.php

index 337cca4..0708576 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,6 +7,7 @@ Version 2019.06 (UNRELEASED) (2019-06-?)
     Fixed tag completion painfully slow [AlfredSK]
     Fixed a regression in notifications [MrPetovan]
     Fixed an issue with smilies and code blocks [MrPetovan]
+    Fixed an AP issue with unavailable local profiles [MrPetovan]
     General Code cleaning and restructuring [nupplaphil]
     Added frio color scheme sharing [JeroenED]
     Added syslog and stream Logger [nupplaphil]
@@ -14,7 +15,7 @@ Version 2019.06 (UNRELEASED) (2019-06-?)
     Added collapsible panel for connector permission fields [MrPetovan]
 
   Closed Issues:
-    6303, 6478, 6319, 6921, 6903
+    6303, 6478, 6319, 6921, 6903, 6943
 
 Version 2019.03 (2019-03-22)
   Friendica Core:
index e43554a..55150a9 100644 (file)
@@ -54,15 +54,21 @@ 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 = ActivityPub\Transmitter::getDeletedUser(self::$which);\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
index eb1da09..6e7bc73 100644 (file)
@@ -247,6 +247,23 @@ class Transmitter
                return $data;
        }
 
+       /**
+        * @param string $username
+        * @return array
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException
+        */
+       public static function getDeletedUser($username)
+       {
+               return [
+                       '@context' => ActivityPub::CONTEXT,
+                       'id' => System::baseUrl() . '/profile/' . $username,
+                       'type' => 'Tombstone',
+                       'published' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+                       'updated' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+                       'deleted' => DateTimeFormat::utcNow(DateTimeFormat::ATOM),
+               ];
+       }
+
        /**
         * Returns an array with permissions of a given item array
         *