]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - actions/apistatusesshow.php
Don't send multiple error responses in ApiMediaUpload :)
[quix0rs-gnu-social.git] / actions / apistatusesshow.php
index 2a7702ee3c7a8735a25892416fb48e639b22590b..70b9a9c27a49427fc3ab6eed4ed5cea7bb92c9d5 100644 (file)
@@ -74,7 +74,16 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
 
         $this->notice_id = (int)$this->trimmed('id');
 
-        $this->notice = Notice::getKV($this->notice_id);
+        $this->notice = Notice::getKV('id', $this->notice_id);
+        if (!$this->notice instanceof Notice) {
+            $deleted = Deleted_notice::getKV('id', $this->notice_id);
+            if ($deleted instanceof Deleted_notice) {
+                // TRANS: Client error displayed trying to show a deleted notice.
+                $this->clientError(_('Notice deleted.'), 410);
+            }
+            // TRANS: Client error displayed trying to show a non-existing notice.
+            $this->clientError(_('No such notice.'), 404);
+        }
         if (!$this->notice->inScope($this->scoped)) {
             // TRANS: Client exception thrown when trying a view a notice the user has no access to.
             throw new ClientException(_('Access restricted.'), 403);
@@ -227,7 +236,7 @@ class ApiStatusesShowAction extends ApiPrivateAuthAction
         }
 
         if (Event::handle('StartDeleteOwnNotice', array($this->auth_user, $this->notice))) {
-            $this->notice->delete();
+            $this->notice->deleteAs($this->scoped);
             Event::handle('EndDeleteOwnNotice', array($this->auth_user, $this->notice));
         }