From 91f368af58860f7133868c84be3eedfd844253f8 Mon Sep 17 00:00:00 2001 From: ghost Date: Thu, 13 Jan 2022 17:51:19 +0200 Subject: [PATCH] add required fields validation --- src/application/controller/api/post/add.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/application/controller/api/post/add.php b/src/application/controller/api/post/add.php index 43e5074..b514911 100644 --- a/src/application/controller/api/post/add.php +++ b/src/application/controller/api/post/add.php @@ -17,10 +17,16 @@ if (isset($_SESSION['userName'])) { } } + if (!isset($_POST['message'])) { - if ($postK && $result = $_twister->newPostMessage($_SESSION['userName'], - $postK, - Filter::post($_POST['message']))) { + $response = [ + 'success' => false, + 'message' => _('Message required') + ]; + + } else if ($postK && $result = $_twister->newPostMessage($_SESSION['userName'], + $postK, + Filter::post($_POST['message']))) { $response = [ 'success' => true,