1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 07:56:23 +00:00

Return last_id = 0 when there is no new messages

This commit is contained in:
Loic Blot 2016-12-06 23:59:41 +01:00
parent 8d335d449e
commit 7fda438397

View File

@ -195,8 +195,12 @@ class ApiController extends Controller {
}
$messages = $this->smsMapper->getMessages($this->userId, $start, $limit);
$last_id = 0;
if (count($messages) > 0) {
$last_id = max(array_keys($messages));
}
return new JSONResponse(array("messages" => $messages, "last_id" => max(array_keys($messages))));
return new JSONResponse(array("messages" => $messages, "last_id" => $last_id));
}
/**