X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FApi%2FMastodon%2FLists.php;h=beb1a3b9a62455fd552f6a2022726c8d6eaa145d;hb=7486ebdc10715b7204b70ce262052d28cb61c69e;hp=ec9ad86a3424eae3eb49170e2c22894219302b40;hpb=5aad46c7fb2b66d63ad93d92ee355fc522b57be1;p=friendica.git diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index ec9ad86a34..beb1a3b9a6 100644 --- a/src/Module/Api/Mastodon/Lists.php +++ b/src/Module/Api/Mastodon/Lists.php @@ -1,6 +1,6 @@ checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } - if (!Group::exists($this->parameters['id'], $uid)) { - DI::mstdnError()->RecordNotFound(); + if (!Circle::exists($this->parameters['id'], $uid)) { + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } - if (!Group::remove($this->parameters['id'])) { + if (!Circle::remove($this->parameters['id'])) { DI::mstdnError()->InternalError(); } - System::jsonExit([]); + $this->jsonExit([]); } - protected function post(array $request = [], array $post = []) + protected function post(array $request = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); - $request = self::getRequest([ + $request = $this->getRequest([ 'title' => '', - ]); + ], $request); if (empty($request['title'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } - Group::create($uid, $request['title']); + Circle::create($uid, $request['title']); - $id = Group::getIdByName($uid, $request['title']); + $id = Circle::getIdByName($uid, $request['title']); if (!$id) { DI::mstdnError()->InternalError(); } - System::jsonExit(DI::mstdnList()->createFromGroupId($id)); + $this->jsonExit(DI::mstdnList()->createFromCircleId($id)); } - public function put() + public function put(array $request = []) { - $request = self::getRequest([ + $request = $this->getRequest([ 'title' => '', // The title of the list to be updated. 'replies_policy' => '', // One of: "followed", "list", or "none". - ]); + ], $request); if (empty($request['title']) || empty($this->parameters['id'])) { - DI::mstdnError()->UnprocessableEntity(); + $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity()); } - Group::update($this->parameters['id'], $request['title']); + Circle::update($this->parameters['id'], $request['title']); } /** @@ -93,26 +93,24 @@ class Lists extends BaseApi */ protected function rawContent(array $request = []) { - self::checkAllowedScope(self::SCOPE_READ); + $this->checkAllowedScope(self::SCOPE_READ); $uid = self::getCurrentUserID(); if (empty($this->parameters['id'])) { $lists = []; - $groups = Group::getByUserId($uid); - - foreach ($groups as $group) { - $lists[] = DI::mstdnList()->createFromGroupId($group['id']); + foreach (Circle::getByUserId($uid) as $circle) { + $lists[] = DI::mstdnList()->createFromCircleId($circle['id']); } } else { $id = $this->parameters['id']; - if (!Group::exists($id, $uid)) { - DI::mstdnError()->RecordNotFound(); + if (!Circle::exists($id, $uid)) { + $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound()); } - $lists = DI::mstdnList()->createFromGroupId($id); + $lists = DI::mstdnList()->createFromCircleId($id); } - System::jsonExit($lists); + $this->jsonExit($lists); } }