X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FApi%2FMastodon%2FAccounts.php;h=6b88b84ef3fac571fc365743abdfbd1e8888cda8;hb=7486ebdc10715b7204b70ce262052d28cb61c69e;hp=f650af0587ce9974e374b0a66731fc31047a0ad4;hpb=4206c5d363abc25e497f6f6cfc55ce9f212c642d;p=friendica.git diff --git a/src/Module/Api/Mastodon/Accounts.php b/src/Module/Api/Mastodon/Accounts.php index f650af0587..6b88b84ef3 100644 --- a/src/Module/Api/Mastodon/Accounts.php +++ b/src/Module/Api/Mastodon/Accounts.php @@ -1,6 +1,6 @@ UnprocessableEntity(); + $uid = self::getCurrentUserID(); + + 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, self::getCurrentUserID()); - System::jsonExit($account); + $account = DI::mstdnAccount()->createFromContactId($id, $uid); + $this->jsonExit($account); } }