X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FApi%2FMastodon%2FLists.php;h=beb1a3b9a62455fd552f6a2022726c8d6eaa145d;hb=7486ebdc10715b7204b70ce262052d28cb61c69e;hp=ec686058ef3ffc8df04cf39389cd162a839c0df9;hpb=1d0955f75939a600a53a377284aac27501a46e0e;p=friendica.git diff --git a/src/Module/Api/Mastodon/Lists.php b/src/Module/Api/Mastodon/Lists.php index ec686058ef..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 = []) { - self::checkAllowedScope(self::SCOPE_WRITE); + $this->checkAllowedScope(self::SCOPE_WRITE); $uid = self::getCurrentUserID(); $request = $this->getRequest([ @@ -61,17 +61,17 @@ class Lists extends BaseApi ], $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(array $request = []) @@ -82,10 +82,10 @@ class Lists extends BaseApi ], $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); } }