1
0
mirror of https://github.com/nextcloud/ocsms.git synced 2026-08-11 16:32:55 +00:00

Add replace function to purge all database before adding every record. Also add a delete before insert function when writing to DB, preventing SMS duplicates

This commit is contained in:
Loic Blot
2014-09-15 18:00:48 +02:00
parent 128167196a
commit ad1353c63c
3 changed files with 23 additions and 10 deletions
+12
View File
@@ -59,6 +59,18 @@ class SmsController extends Controller {
return new JSONResponse(array("status" => true, "msg" => "OK"));
}
/**
* @NoAdminRequired
*/
public function replace($smsCount, $smsDatas) {
if ($this->checkPushStructure($smsCount, $smsDatas, true) === false) {
return new JSONResponse(array("status" => false, "msg" => $this->errorMsg));
}
$this->smsMapper->writeToDB($this->userId, $smsDatas, true);
return new JSONResponse(array("status" => true, "msg" => "OK"));
}
private function checkPushStructure ($smsCount, $smsDatas) {
if ($smsCount != count($smsDatas)) {
$this->errorMsg = "Error: sms count invalid";