Move jsonError out of Factory\Api\Mastodon\Error->UnprocessableEntity
This commit is contained in:
parent
7f846f153d
commit
7486ebdc10
|
@ -57,14 +57,11 @@ class Error extends BaseFactory
|
|||
return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
}
|
||||
|
||||
public function UnprocessableEntity(string $error = '')
|
||||
public function UnprocessableEntity(string $error = ''): \Friendica\Object\Api\Mastodon\Error
|
||||
{
|
||||
$error = $error ?: $this->l10n->t('Unprocessable Entity');
|
||||
$error_description = '';
|
||||
$errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
|
||||
$this->logError(422, $error);
|
||||
$this->jsonError(422, $errorObj->toArray());
|
||||
return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
|
||||
}
|
||||
|
||||
public function Unauthorized(string $error = '', string $error_description = '')
|
||||
|
|
|
@ -39,7 +39,7 @@ class Dislike extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
|
|
@ -41,7 +41,7 @@ class DislikedBy extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -39,7 +39,7 @@ class Undislike extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
|
|
@ -40,7 +40,7 @@ class Accounts extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id']) && empty($this->parameters['name'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!empty($this->parameters['id'])) {
|
||||
|
|
|
@ -38,7 +38,7 @@ class Block extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Contact\User::setBlocked($this->parameters['id'], $uid, true);
|
||||
|
|
|
@ -37,7 +37,7 @@ class Follow extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -41,7 +41,7 @@ class Followers extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -41,7 +41,7 @@ class Following extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -41,7 +41,7 @@ class Lists extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -37,7 +37,7 @@ class Mute extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Contact\User::setIgnored($this->parameters['id'], $uid, true);
|
||||
|
|
|
@ -38,7 +38,7 @@ class Note extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -44,7 +44,7 @@ class Relationships extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($request['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!is_array($request['id'])) {
|
||||
|
|
|
@ -47,7 +47,7 @@ class Statuses extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -37,7 +37,7 @@ class Unblock extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Contact\User::setBlocked($this->parameters['id'], $uid, false);
|
||||
|
|
|
@ -37,7 +37,7 @@ class Unfollow extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$cdata = Contact::getPublicAndUserContactID($this->parameters['id'], $uid);
|
||||
|
|
|
@ -37,7 +37,7 @@ class Unmute extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Contact\User::setIgnored($this->parameters['id'], $uid, false);
|
||||
|
|
|
@ -70,7 +70,7 @@ class Apps extends BaseApi
|
|||
}
|
||||
|
||||
if (empty($request['client_name']) || empty($request['redirect_uris'])) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Missing parameters'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Missing parameters')));
|
||||
}
|
||||
|
||||
$client_id = bin2hex(random_bytes(32));
|
||||
|
|
|
@ -38,7 +38,7 @@ class Conversations extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (!empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
DBA::delete('conv', ['id' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
|
|
@ -38,7 +38,7 @@ class Read extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (!empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
DBA::update('mail', ['seen' => true], ['convid' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
|
|
@ -37,7 +37,7 @@ class Lists extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!Circle::exists($this->parameters['id'], $uid)) {
|
||||
|
@ -61,7 +61,7 @@ class Lists extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($request['title'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Circle::create($uid, $request['title']);
|
||||
|
@ -82,7 +82,7 @@ class Lists extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($request['title']) || empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Circle::update($this->parameters['id'], $request['title']);
|
||||
|
|
|
@ -43,7 +43,7 @@ class Accounts extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($request['account_ids']) || empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
return Circle::removeMembers($this->parameters['id'], $request['account_ids']);
|
||||
|
@ -58,7 +58,7 @@ class Accounts extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($request['account_ids']) || empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Circle::addMembers($this->parameters['id'], $request['account_ids']);
|
||||
|
@ -73,7 +73,7 @@ class Accounts extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -48,7 +48,7 @@ class Markers extends BaseApi
|
|||
}
|
||||
|
||||
if (empty($timeline) || empty($last_read_id) || empty($application['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$condition = ['application-id' => $application['id'], 'uid' => $uid, 'timeline' => $timeline];
|
||||
|
|
|
@ -48,12 +48,12 @@ class Media extends BaseApi
|
|||
Logger::info('Photo post', ['request' => $request, 'files' => $_FILES]);
|
||||
|
||||
if (empty($_FILES['file'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$media = Photo::upload($uid, $_FILES['file'], '', null, null, '', '', $request['description']);
|
||||
if (empty($media)) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
Logger::info('Uploaded photo', ['media' => $media]);
|
||||
|
@ -74,7 +74,7 @@ class Media extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$photo = Photo::selectFirst(['resource-id'], ['id' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
@ -104,7 +104,7 @@ class Media extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -40,7 +40,7 @@ class Mutes extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -38,7 +38,7 @@ class Dismiss extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$condition = ['id' => $this->parameters['id']];
|
||||
|
|
|
@ -39,7 +39,7 @@ class Polls extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$this->jsonExit(DI::mstdnPoll()->createFromId($this->parameters['id'], $uid));
|
||||
|
|
|
@ -47,7 +47,7 @@ class ScheduledStatuses extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!DBA::exists('delayed-post', ['id' => $this->parameters['id'], 'uid' => $uid])) {
|
||||
|
|
|
@ -60,7 +60,7 @@ class Search extends BaseApi
|
|||
], $request);
|
||||
|
||||
if (empty($request['q'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$limit = min($request['limit'], 40);
|
||||
|
|
|
@ -319,7 +319,7 @@ class Statuses extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectFirstForUser($uid, ['id'], ['uri-id' => $this->parameters['id'], 'uid' => $uid]);
|
||||
|
@ -342,7 +342,7 @@ class Statuses extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$this->jsonExit(DI::mstdnStatus()->createFromUriId($this->parameters['id'], $uid, self::appSupportsQuotes(), false));
|
||||
|
|
|
@ -39,7 +39,7 @@ class Bookmark extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
|
||||
|
@ -48,7 +48,7 @@ class Bookmark extends BaseApi
|
|||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be bookmarked'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be bookmarked')));
|
||||
}
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
|
|
|
@ -40,7 +40,7 @@ class Card extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
|
||||
|
|
|
@ -41,7 +41,7 @@ class Context extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -39,7 +39,7 @@ class Favourite extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
|
|
@ -41,7 +41,7 @@ class FavouritedBy extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
|
||||
|
|
|
@ -39,7 +39,7 @@ class Mute extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
@ -48,7 +48,7 @@ class Mute extends BaseApi
|
|||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be muted'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be muted')));
|
||||
}
|
||||
|
||||
Post\ThreadUser::setIgnored($item['uri-id'], $uid, true);
|
||||
|
|
|
@ -38,7 +38,7 @@ class Pin extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity', 'author-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
|
|
@ -42,7 +42,7 @@ class Reblog extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
@ -53,7 +53,10 @@ class Reblog extends BaseApi
|
|||
if ($item['network'] == Protocol::DIASPORA) {
|
||||
Diaspora::performReshare($this->parameters['id'], $uid);
|
||||
} elseif (!in_array($item['network'], [Protocol::DFRN, Protocol::ACTIVITYPUB, Protocol::TWITTER])) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network'])));
|
||||
$this->logErrorAndJsonExit(
|
||||
422,
|
||||
$this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be shared", ContactSelector::networkToName($item['network'])))
|
||||
);
|
||||
} else {
|
||||
Item::performActivity($item['id'], 'announce', $uid);
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class RebloggedBy extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if (!$post = Post::selectOriginal(['uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [0, $uid]])) {
|
||||
|
|
|
@ -41,7 +41,7 @@ class Source extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$id = $this->parameters['id'];
|
||||
|
|
|
@ -39,7 +39,7 @@ class Unbookmark extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginal(['uid', 'id', 'uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]], ['order' => ['uid' => true]]);
|
||||
|
@ -48,7 +48,7 @@ class Unbookmark extends BaseApi
|
|||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unbookmarked'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unbookmarked')));
|
||||
}
|
||||
|
||||
if ($item['uid'] == 0) {
|
||||
|
|
|
@ -39,7 +39,7 @@ class Unfavourite extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
|
|
@ -39,7 +39,7 @@ class Unmute extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
@ -48,7 +48,7 @@ class Unmute extends BaseApi
|
|||
}
|
||||
|
||||
if ($item['gravity'] != Item::GRAVITY_PARENT) {
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Only starting posts can be unmuted'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Only starting posts can be unmuted')));
|
||||
}
|
||||
|
||||
Post\ThreadUser::setIgnored($item['uri-id'], $uid, false);
|
||||
|
|
|
@ -38,7 +38,7 @@ class Unpin extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['uri-id', 'gravity'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
|
|
@ -41,7 +41,7 @@ class Unreblog extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$item = Post::selectOriginalForUser($uid, ['id', 'uri-id', 'network'], ['uri-id' => $this->parameters['id'], 'uid' => [$uid, 0]]);
|
||||
|
@ -59,7 +59,10 @@ class Unreblog extends BaseApi
|
|||
$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'])));
|
||||
$this->logErrorAndJsonExit(
|
||||
422,
|
||||
$this->errorFactory->UnprocessableEntity($this->t("Posts from %s can't be unshared", ContactSelector::networkToName($item['network'])))
|
||||
);
|
||||
} else {
|
||||
Item::performActivity($item['id'], 'unannounce', $uid);
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ class Tags extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['hashtag'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$tag = ltrim($this->parameters['hashtag'], '#');
|
||||
|
|
|
@ -37,7 +37,7 @@ class Follow extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['hashtag'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$fields = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')];
|
||||
|
|
|
@ -37,7 +37,7 @@ class Unfollow extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['hashtag'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$term = ['uid' => $uid, 'term' => '#' . ltrim($this->parameters['hashtag'], '#')];
|
||||
|
|
|
@ -45,7 +45,7 @@ class ListTimeline extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['id'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
$request = $this->getRequest([
|
||||
|
|
|
@ -45,7 +45,7 @@ class Tag extends BaseApi
|
|||
$uid = self::getCurrentUserID();
|
||||
|
||||
if (empty($this->parameters['hashtag'])) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,17 +51,17 @@ class Authorize extends BaseApi
|
|||
|
||||
if ($request['response_type'] != 'code') {
|
||||
Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]);
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing response type'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type')));
|
||||
}
|
||||
|
||||
if (empty($request['client_id']) || empty($request['redirect_uri'])) {
|
||||
Logger::warning('Incomplete request data', ['request' => $_REQUEST]);
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Incomplete request data'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data')));
|
||||
}
|
||||
|
||||
$application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
|
||||
if (empty($application)) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
// @todo Compare the application scope and requested scope
|
||||
|
@ -87,7 +87,7 @@ class Authorize extends BaseApi
|
|||
|
||||
$token = OAuth::createTokenForUser($application, $uid, $request['scope']);
|
||||
if (!$token) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') {
|
||||
|
|
|
@ -105,7 +105,7 @@ class Token extends BaseApi
|
|||
$me = $owner['url'];
|
||||
} else {
|
||||
Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing grant type'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type')));
|
||||
}
|
||||
|
||||
$object = new \Friendica\Object\Api\Mastodon\Token($token['access_token'], 'Bearer', $application['scopes'], $token['created_at'], $me);
|
||||
|
|
Loading…
Reference in New Issue
Block a user