Delete return pages

This commit is contained in:
2024-07-27 17:01:24 +02:00
parent ce7ba50b9d
commit 6018e8bee5
4 changed files with 20 additions and 7 deletions
+4 -2
View File
@@ -30,7 +30,7 @@ class Posts extends Api
// Throw 400 error if a required one is missing.
$content = Input::post("content");
// This one is optional
$limit = constrain(0, 30, intval(Input::post("limit", 10)));
$limit = constrain(0, 30, intval(Input::get("l", 10)));
if (empty($content)) throw ApiError::missingField(["content"]);
// Get logged in user
@@ -77,9 +77,11 @@ class Posts extends Api
public function delete($id): void
{
// Fetch ax(0, intval(Input::get("p", 0)));
$limit = constrain(0, 30, intval(Input::get("l", 10)));
// Try delete, 404 if post was not found.
try {
Response::json(Post::getByID($id)->delete());
Response::json(Post::getByID($id)->delete($limit));
} catch (Exception $err) {
switch ($err->getMessage()) {
case "NotFound":
+3 -1
View File
@@ -281,7 +281,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/PostResponse"
$ref: "#/components/schemas/PostDeleteResponse"
404:
description: Post not found.
content:
@@ -697,6 +697,8 @@ components:
type: number
post:
$ref: "#/components/schemas/PostResponse"
PostDeleteResponse:
$ref: "#/components/schemas/PostCreateResponse"
PostListResponse:
type: object
properties:
File diff suppressed because one or more lines are too long