]> git.mxchange.org Git - friendica.git/blobdiff - src/Module/Api/Mastodon/Lists.php
Move jsonError out of Factory\Api\Mastodon\Error->UnprocessableEntity
[friendica.git] / src / Module / Api / Mastodon / Lists.php
index 296009cc083b381fb2c380e7699ba9261b1de92b..beb1a3b9a62455fd552f6a2022726c8d6eaa145d 100644 (file)
@@ -33,15 +33,15 @@ class Lists extends BaseApi
 {
        protected function delete(array $request = [])
        {
-               self::checkAllowedScope(self::SCOPE_WRITE);
+               $this->checkAllowedScope(self::SCOPE_WRITE);
                $uid = self::getCurrentUserID();
 
                if (empty($this->parameters['id'])) {
-                       DI::mstdnError()->UnprocessableEntity();
+                       $this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
                }
 
                if (!Circle::exists($this->parameters['id'], $uid)) {
-                       DI::mstdnError()->RecordNotFound();
+                       $this->logErrorAndJsonExit(404, $this->errorFactory->RecordNotFound());
                }
 
                if (!Circle::remove($this->parameters['id'])) {
@@ -53,7 +53,7 @@ class Lists extends BaseApi
 
        protected function post(array $request = [])
        {
-               self::checkAllowedScope(self::SCOPE_WRITE);
+               $this->checkAllowedScope(self::SCOPE_WRITE);
                $uid = self::getCurrentUserID();
 
                $request = $this->getRequest([
@@ -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']);
@@ -93,7 +93,7 @@ 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'])) {
@@ -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);
                }