]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Api/Mastodon/Accounts.php
Move jsonError out of Factory\Api\Mastodon\Error->UnprocessableEntity
[friendica.git] / src / Module / Api / Mastodon / Accounts.php
index 781547854aada3932d0e753ad33726b608ba2e94..6b88b84ef3fac571fc365743abdfbd1e8888cda8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 /**
- * @copyright Copyright (C) 2010-2021, the Friendica project
+ * @copyright Copyright (C) 2010-2023, the Friendica project
  *
  * @license GNU AGPL version 3 or any later version
  *
@@ -33,32 +33,31 @@ use Friendica\Module\BaseApi;
 class Accounts extends BaseApi
 {
        /**
-        * @param array $parameters
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public static function rawContent(array $parameters = [])
+       protected function rawContent(array $request = [])
        {
                $uid = self::getCurrentUserID();
 
-               if (empty($parameters['id']) && empty($parameters['name'])) {
-                       DI::mstdnError()->UnprocessableEntity();
+               if (empty($this->parameters['id']) && empty($this->parameters['name'])) {
+                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
                }
 
-               if (!empty($parameters['id'])) {
-                       $id = $parameters['id'];
+               if (!empty($this->parameters['id'])) {
+                       $id = $this->parameters['id'];
                        if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
-                               DI::mstdnError()->RecordNotFound();
+                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
                        }
                } else {
-                       $contact = Contact::selectFirst(['id'], ['nick' => $parameters['name'], 'uid' => 0]);
+                       $contact = Contact::selectFirst(['id'], ['nick' => $this->parameters['name'], 'uid' => 0]);
                        if (!empty($contact['id'])) {
                                $id = $contact['id'];
-                       } elseif (!($id = Contact::getIdForURL($parameters['name'], 0, false))) {
-                               DI::mstdnError()->RecordNotFound();
+                       } elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) {
+                               $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
                        }
                }
 
                $account = DI::mstdnAccount()->createFromContactId($id, $uid);
-               System::jsonExit($account);
+               $this->jsonExit($account);
        }
 }