From f579d687a93d7e6fb923bafc2aa076cdd61de42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Sat, 13 Aug 2022 22:31:38 +0200 Subject: [PATCH] Fixes: - fixed $this usage (kept) and got rid of static context - "imported" exception class - added some nice text to it --- src/Module/Xrd.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Module/Xrd.php b/src/Module/Xrd.php index 810424504..21a0e5cd4 100644 --- a/src/Module/Xrd.php +++ b/src/Module/Xrd.php @@ -28,6 +28,7 @@ use Friendica\Core\System; use Friendica\DI; use Friendica\Model\Photo; use Friendica\Model\User; +use Friendica\Network\HTTPException\NotFoundException; use Friendica\Protocol\ActivityNamespace; use Friendica\Protocol\Salmon; @@ -77,19 +78,19 @@ class Xrd extends BaseModule if ($name == User::getActorName()) { $owner = User::getSystemAccount(); if (empty($owner)) { - throw new \Friendica\Network\HTTPException\NotFoundException(); + throw new NotFoundException('System account was not found. Please setup your Friendica installation properly.'); } - self::printSystemJSON($owner); + $this->printSystemJSON($owner); } else { $user = User::getByNickname($name); if (empty($user)) { - throw new \Friendica\Network\HTTPException\NotFoundException(); + throw new NotFoundException('User was not found for name=' . $name); } $owner = User::getOwnerDataById($user['uid']); if (empty($owner)) { DI::logger()->warning('No owner data for user id', ['uri' => $uri, 'name' => $name, 'user' => $user]); - throw new \Friendica\Network\HTTPException\NotFoundException(); + throw new NotFoundException('Owner was not found for user->uid=' . $user['uid']); } $alias = str_replace('/profile/', '/~', $owner['url']); @@ -102,13 +103,13 @@ class Xrd extends BaseModule } if ($mode == Response::TYPE_XML) { - self::printXML($alias, $user, $owner, $avatar); + $this->printXML($alias, $user, $owner, $avatar); } else { - self::printJSON($alias, $owner, $avatar); + $this->printJSON($alias, $owner, $avatar); } } - private static function printSystemJSON(array $owner) + private function printSystemJSON(array $owner) { $baseURL = $this->baseurl->get(); $json = [ @@ -154,7 +155,7 @@ class Xrd extends BaseModule System::jsonExit($json, 'application/jrd+json; charset=utf-8'); } - private static function printJSON(string $alias, array $owner, array $avatar) + private function printJSON(string $alias, array $owner, array $avatar) { $baseURL = $this->baseurl->get(); $salmon_key = Salmon::salmonKey($owner['spubkey']); @@ -236,7 +237,7 @@ class Xrd extends BaseModule System::jsonExit($json, 'application/jrd+json; charset=utf-8'); } - private static function printXML(string $alias, array $user, array $owner, array $avatar) + private function printXML(string $alias, array $user, array $owner, array $avatar) { $baseURL = $this->baseurl->get(); $salmon_key = Salmon::salmonKey($owner['spubkey']);