Move jsonError out of Factory\Api\Mastodon\Error->RecordNotFound

This commit is contained in:
Hypolite Petovan 2023-10-11 09:16:03 -04:00
parent 9e71610711
commit 7f846f153d
36 changed files with 68 additions and 56 deletions

View file

@ -50,14 +50,11 @@ class Error extends BaseFactory
$this->logger->info('API Error', ['no' => $errorno, 'error' => $error, 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
}
public function RecordNotFound()
public function RecordNotFound(): \Friendica\Object\Api\Mastodon\Error
{
$error = $this->l10n->t('Record not found');
$error_description = '';
$errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
$this->logError(404, $error);
$this->jsonError(404, $errorObj->toArray());
return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
}
public function UnprocessableEntity(string $error = '')

View file

@ -359,7 +359,7 @@ class Status extends BaseFactory
{
$item = ActivityPub\Transmitter::getItemArrayFromMail($id, true);
if (empty($item)) {
$this->mstdnErrorFactory->RecordNotFound();
throw new HTTPException\NotFoundException('Mail record not found with id: ' . $id);
}
$account = $this->mstdnAccountFactory->createFromContactId($item['author-id']);