From efd9232c9448feb1b658241dec8e7897d662c2f4 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 6 Oct 2022 13:18:15 -0700 Subject: [PATCH] Allow POST for day --- appinfo/routes.php | 1 + lib/Controller/ApiController.php | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/appinfo/routes.php b/appinfo/routes.php index a78b0e13..dcf300ea 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -18,6 +18,7 @@ return [ // API ['name' => 'api#days', 'url' => '/api/days', 'verb' => 'GET'], ['name' => 'api#day', 'url' => '/api/days/{id}', 'verb' => 'GET'], + ['name' => 'api#day', 'url' => '/api/days/{id}', 'verb' => 'POST'], ['name' => 'api#imageInfo', 'url' => '/api/info/{id}', 'verb' => 'GET'], ['name' => 'api#imageEdit', 'url' => '/api/edit/{id}', 'verb' => 'PATCH'], ['name' => 'api#archive', 'url' => '/api/archive/{id}', 'verb' => 'PATCH'], diff --git a/lib/Controller/ApiController.php b/lib/Controller/ApiController.php index 345d0333..6263c049 100644 --- a/lib/Controller/ApiController.php +++ b/lib/Controller/ApiController.php @@ -183,6 +183,14 @@ class ApiController extends Controller { } $uid = $user->getUID(); + // Check if post request + if ($this->request->getMethod() === 'POST') { + $id = $this->request->getParam('body_ids'); + if (is_null($id)) { + return new JSONResponse([], Http::STATUS_BAD_REQUEST); + } + } + // Split at commas and convert all parts to int $day_ids = array_map(function ($part) { return intval($part);