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:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user