1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-07-16 22:46:49 +00:00

apicontroller.php: Return error 400 when messages are not accepted on push

This commit is contained in:
Loic Blot 2017-12-28 16:56:31 +01:00
parent 7dd75ea74a
commit 9a6d6907cf
No known key found for this signature in database
GPG Key ID: EFAA458E8C153987

View File

@ -76,7 +76,10 @@ class ApiController extends Controller {
*/
public function push ($smsCount, $smsDatas) {
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
return new JSONResponse(array("status" => false, "msg" => $this->errorMsg));
return new JSONResponse(
array("status" => false, "msg" => $this->errorMsg),
Http::STATUS_BAD_REQUEST
);
}
$this->smsMapper->writeToDB($this->userId, $smsDatas);
@ -90,8 +93,11 @@ class ApiController extends Controller {
* @return JSONResponse
*/
public function replace($smsCount, $smsDatas) {
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
return new JSONResponse(array("status" => false, "msg" => $this->errorMsg));
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
return new JSONResponse(
array("status" => false, "msg" => $this->errorMsg),
Http::STATUS_BAD_REQUEST
);
}
$this->smsMapper->writeToDB($this->userId, $smsDatas, true);
@ -103,7 +109,7 @@ class ApiController extends Controller {
* @param $smsDatas
* @return bool
*/
private function checkPushStructure ($smsCount, $smsDatas) {
private function checkPushStructure (&$smsCount, &$smsDatas) {
if ($smsCount === NULL) {
$this->errorMsg = "Error: smsCount field is NULL";
return false;