mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-07-17 06:56:02 +00:00
apicontroller.php: Return error 400 when messages are not accepted on push
This commit is contained in:
parent
7dd75ea74a
commit
9a6d6907cf
@ -76,7 +76,10 @@ class ApiController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function push ($smsCount, $smsDatas) {
|
public function push ($smsCount, $smsDatas) {
|
||||||
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
|
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);
|
$this->smsMapper->writeToDB($this->userId, $smsDatas);
|
||||||
@ -90,8 +93,11 @@ class ApiController extends Controller {
|
|||||||
* @return JSONResponse
|
* @return JSONResponse
|
||||||
*/
|
*/
|
||||||
public function replace($smsCount, $smsDatas) {
|
public function replace($smsCount, $smsDatas) {
|
||||||
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
|
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, true);
|
$this->smsMapper->writeToDB($this->userId, $smsDatas, true);
|
||||||
@ -103,7 +109,7 @@ class ApiController extends Controller {
|
|||||||
* @param $smsDatas
|
* @param $smsDatas
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function checkPushStructure ($smsCount, $smsDatas) {
|
private function checkPushStructure (&$smsCount, &$smsDatas) {
|
||||||
if ($smsCount === NULL) {
|
if ($smsCount === NULL) {
|
||||||
$this->errorMsg = "Error: smsCount field is NULL";
|
$this->errorMsg = "Error: smsCount field is NULL";
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user