Move jsonError out of Factory\Api\Mastodon\Error->RecordNotFound
This commit is contained in:
parent
9e71610711
commit
7f846f153d
36 changed files with 68 additions and 56 deletions
|
@ -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 = '')
|
||||
|
|
|
@ -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']);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Dislike extends BaseApi
|
|||
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Item::performActivity($item['id'], 'dislike', $uid);
|
||||
|
|
|
@ -46,7 +46,7 @@ class DislikedBy extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!Post::exists(['uri-id' => $id, 'uid' => [0, $uid]])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $id, 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::DISLIKE, 'deleted' => false]);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Undislike extends BaseApi
|
|||
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Item::performActivity($item['id'], 'undislike', $uid);
|
||||
|
|
|
@ -46,14 +46,14 @@ class Accounts extends BaseApi
|
|||
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' => $this->parameters['name'], 'uid' => 0]);
|
||||
if (!empty($contact['id'])) {
|
||||
$id = $contact['id'];
|
||||
} elseif (!($id = Contact::getIdForURL($this->parameters['name'], 0, false))) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class Followers extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -46,7 +46,7 @@ class Following extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -46,7 +46,7 @@ class Lists extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$lists = [];
|
||||
|
|
|
@ -47,7 +47,7 @@ class Note extends BaseApi
|
|||
|
||||
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Contact::update(['info' => $request['comment']], ['id' => $cdata['user']]);
|
||||
|
|
|
@ -52,7 +52,7 @@ class Statuses extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -42,7 +42,7 @@ class Unfollow extends BaseApi
|
|||
|
||||
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
|
||||
if (empty($cdata['user'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$contact = Contact::getById($cdata['user']);
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/timelines/conversations/
|
||||
|
@ -83,9 +84,13 @@ class Conversations extends BaseApi
|
|||
|
||||
$conversations = [];
|
||||
|
||||
while ($conv = DBA::fetch($convs)) {
|
||||
self::setBoundaries($conv['id']);
|
||||
$conversations[] = DI::mstdnConversation()->createFromConvId($conv['id']);
|
||||
try {
|
||||
while ($conv = DBA::fetch($convs)) {
|
||||
self::setBoundaries($conv['id']);
|
||||
$conversations[] = DI::mstdnConversation()->createFromConvId($conv['id']);
|
||||
}
|
||||
} catch (NotFoundException $e) {
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
DBA::close($convs);
|
||||
|
|
|
@ -25,6 +25,7 @@ use Friendica\Core\System;
|
|||
use Friendica\Database\DBA;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/timelines/conversations/
|
||||
|
@ -42,6 +43,10 @@ class Read extends BaseApi
|
|||
|
||||
DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
||||
$this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray());
|
||||
try {
|
||||
$this->jsonExit(DI::mstdnConversation()->createFromConvId($this->parameters['id'])->toArray());
|
||||
} catch (NotFoundException $e) {
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class Lists extends BaseApi
|
|||
}
|
||||
|
||||
if (!Circle::exists($this->parameters['id'], $uid)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if (!Circle::remove($this->parameters['id'])) {
|
||||
|
@ -106,7 +106,7 @@ class Lists extends BaseApi
|
|||
$id = $this->parameters['id'];
|
||||
|
||||
if (!Circle::exists($id, $uid)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
$lists = DI::mstdnList()->createFromCircleId($id);
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class Accounts extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!DBA::exists('group', ['id' => $id, 'uid' => $uid])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -81,10 +81,10 @@ class Media extends BaseApi
|
|||
if (empty($photo['resource-id'])) {
|
||||
$media = Post\Media::getById($this->parameters['id']);
|
||||
if (empty($media['uri-id'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
if (!Post::exists(['uri-id' => $media['uri-id'], 'uid' => $uid, 'origin' => true])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
Post\Media::updateById(['description' => $request['description']], $this->parameters['id']);
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromId($this->parameters['id']));
|
||||
|
@ -109,7 +109,7 @@ class Media extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!Photo::exists(['id' => $id, 'uid' => $uid])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$this->jsonExit(DI::mstdnAttachment()->createFromPhoto($id));
|
||||
|
|
|
@ -45,7 +45,7 @@ class Mutes extends BaseApi
|
|||
|
||||
$id = $this->parameters['id'];
|
||||
if (!DBA::exists('contact', ['id' => $id, 'uid' => 0])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -50,7 +50,7 @@ class Notifications extends BaseApi
|
|||
$notification = DI::notification()->selectOneForUser($uid, ['id' => $id]);
|
||||
$this->jsonExit(DI::mstdnNotification()->createFromNotification($notification, self::appSupportsQuotes()));
|
||||
} catch (\Exception $e) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ class PushSubscription extends BaseApi
|
|||
$subscription = Subscription::select($application['id'], $uid, ['id']);
|
||||
if (empty($subscription)) {
|
||||
$this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]);
|
||||
$this->errorFactory->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$fields = [
|
||||
|
@ -145,7 +145,7 @@ class PushSubscription extends BaseApi
|
|||
|
||||
if (!Subscription::exists($application['id'], $uid)) {
|
||||
$this->logger->info('Subscription not found', ['application-id' => $application['id'], 'uid' => $uid]);
|
||||
$this->errorFactory->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$this->logger->info('Fetch subscription', ['application-id' => $application['id'], 'uid' => $uid]);
|
||||
|
|
|
@ -51,7 +51,7 @@ class ScheduledStatuses extends BaseApi
|
|||
}
|
||||
|
||||
if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Post\Delayed::deleteById($this->parameters['id']);
|
||||
|
|
|
@ -324,11 +324,11 @@ class Statuses extends BaseApi
|
|||
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]);
|
||||
if (empty($item['id'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if (!Item::markForDeletionById($item['id'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$this->jsonExit([]);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Bookmark extends BaseApi
|
|||
|
||||
$item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
|
@ -56,10 +56,10 @@ class Bookmark extends BaseApi
|
|||
if (!empty($stored)) {
|
||||
$item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
} else {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class Context extends BaseApi
|
|||
}
|
||||
DBA::close($posts);
|
||||
} else {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class Favourite extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Item::performActivity($item['id'], 'like', $uid);
|
||||
|
|
|
@ -45,7 +45,7 @@ class FavouritedBy extends BaseApi
|
|||
}
|
||||
|
||||
if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::LIKE, 'deleted' => false]);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Mute extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
|
|
|
@ -43,7 +43,7 @@ class Pin extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Post\Collection::add($item['uri-id'], Post\Collection::FEATURED, $item['author-id'], $uid);
|
||||
|
|
|
@ -47,7 +47,7 @@ class Reblog extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if ($item['network'] == Protocol::DIASPORA) {
|
||||
|
|
|
@ -45,7 +45,7 @@ class RebloggedBy extends BaseApi
|
|||
}
|
||||
|
||||
if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
$activities = Post::selectPosts(['author-id'], ['thr-parent-id' => $post['uri-id'], 'gravity' => Item::GRAVITY_ACTIVITY, 'verb' => Activity::ANNOUNCE]);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Unbookmark extends BaseApi
|
|||
|
||||
$item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
|
@ -56,10 +56,10 @@ class Unbookmark extends BaseApi
|
|||
if (!empty($stored)) {
|
||||
$item = Post::selectFirst(['id', 'gravity'], ['id' => $stored]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
} else {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class Unfavourite extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Item::performActivity($item['id'], 'unlike', $uid);
|
||||
|
|
|
@ -44,7 +44,7 @@ class Unmute extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
|
|
|
@ -43,7 +43,7 @@ class Unpin extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
Post\Collection::remove($item['uri-id'], Post\Collection::FEATURED, $uid);
|
||||
|
|
|
@ -46,17 +46,17 @@ class Unreblog extends BaseApi
|
|||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
if (!DBA::isResult($item)) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if ($item['network'] == Protocol::DIASPORA) {
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['quote-uri-id' => $this->parameters['id'], 'body' => '', 'origin' => true, 'uid' => $uid]);
|
||||
if (empty($item['id'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if (!Item::markForDeletionById($item['id'])) {
|
||||
DI::mstdnError()->RecordNotFound();
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
} elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network'])));
|
||||
|
|
|
@ -26,6 +26,7 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Network\HTTPException;
|
||||
use Friendica\Network\HTTPException\NotFoundException;
|
||||
|
||||
/**
|
||||
* @see https://docs.joinmastodon.org/methods/timelines/
|
||||
|
@ -76,9 +77,13 @@ class Direct extends BaseApi
|
|||
|
||||
$statuses = [];
|
||||
|
||||
while ($mail = DBA::fetch($mails)) {
|
||||
self::setBoundaries($mail['uri-id']);
|
||||
$statuses[] = DI::mstdnStatus()->createFromMailId($mail['id']);
|
||||
try {
|
||||
while ($mail = DBA::fetch($mails)) {
|
||||
self::setBoundaries($mail['uri-id']);
|
||||
$statuses[] = DI::mstdnStatus()->createFromMailId($mail['id']);
|
||||
}
|
||||
} catch (NotFoundException $e) {
|
||||
$this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
|
||||
}
|
||||
|
||||
if (!empty($request['min_id'])) {
|
||||
|
|
Loading…
Reference in a new issue