mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-07-17 15:05:56 +00:00
Add query + routes to drop all user messages
This commit is contained in:
parent
615ba409e5
commit
267872b396
@ -27,6 +27,7 @@ $application->registerRoutes($this, array('routes' => array(
|
|||||||
array('name' => 'sms#retrieve_all_peers', 'url' => '/front-api/v1/peerlist', 'verb' => 'GET'),
|
array('name' => 'sms#retrieve_all_peers', 'url' => '/front-api/v1/peerlist', 'verb' => 'GET'),
|
||||||
array('name' => 'sms#get_conversation', 'url' => '/front-api/v1/conversation', 'verb' => 'GET'),
|
array('name' => 'sms#get_conversation', 'url' => '/front-api/v1/conversation', 'verb' => 'GET'),
|
||||||
array('name' => 'sms#check_new_messages', 'url' => '/front-api/v1/new_messages', 'verb' => 'GET'),
|
array('name' => 'sms#check_new_messages', 'url' => '/front-api/v1/new_messages', 'verb' => 'GET'),
|
||||||
|
array('name' => 'sms#wipe_all_user_messages', 'url' => '/front-api/v1/delete/all', 'verb' => 'POST'),
|
||||||
array('name' => 'settings#get_settings', 'url'=> '/front-api/v1/settings', 'verb' => 'GET'),
|
array('name' => 'settings#get_settings', 'url'=> '/front-api/v1/settings', 'verb' => 'GET'),
|
||||||
|
|
||||||
// Android API v1 doesn't have a version in the URL, be careful
|
// Android API v1 doesn't have a version in the URL, be careful
|
||||||
|
@ -211,7 +211,7 @@ class SmsController extends Controller {
|
|||||||
$this->smsMapper->removeMessagesForPhoneNumber($this->userId, $phnumber);
|
$this->smsMapper->removeMessagesForPhoneNumber($this->userId, $phnumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new JSONResponse(array());
|
return new JSONResponse(array("status" => "ok"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -263,6 +263,16 @@ class SmsController extends Controller {
|
|||||||
return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
|
return new JSONResponse(array(), Http::STATUS_BAD_REQUEST);
|
||||||
}
|
}
|
||||||
$this->smsMapper->removeMessage($this->userId, $phoneNumber, $messageId);
|
$this->smsMapper->removeMessage($this->userId, $phoneNumber, $messageId);
|
||||||
return new JSONResponse(array());
|
return new JSONResponse(array("status" => "ok"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
* @NoCSRFRequired
|
||||||
|
* @return JSONResponse
|
||||||
|
*/
|
||||||
|
public function wipeAllUserMessages () {
|
||||||
|
$this->smsMapper->removeAllMessagesForUser($this->userId);
|
||||||
|
return new JSONResponse(array("status" => "ok"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,6 +227,15 @@ class SmsMapper extends Mapper {
|
|||||||
return $cnt;
|
return $cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function removeAllMessagesForUser ($userId) {
|
||||||
|
$this->db->beginTransaction();
|
||||||
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
$qb->delete('ocsms_smsdatas')
|
||||||
|
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)));
|
||||||
|
$qb->execute();
|
||||||
|
$this->db->commit();
|
||||||
|
}
|
||||||
|
|
||||||
public function removeMessagesForPhoneNumber ($userId, $phoneNumber) {
|
public function removeMessagesForPhoneNumber ($userId, $phoneNumber) {
|
||||||
$this->db->beginTransaction();
|
$this->db->beginTransaction();
|
||||||
$qb = $this->db->getQueryBuilder();
|
$qb = $this->db->getQueryBuilder();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user