mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +00:00
Add two new API calls: getApiVersion and getAllIdsWithStatus
This commit is contained in:
parent
8afe38e132
commit
a933c53fb8
@ -18,6 +18,8 @@ $application->registerRoutes($this, array('routes' => array(
|
||||
array('name' => 'sms#push', 'url' => '/push', 'verb' => 'POST'),
|
||||
array('name' => 'sms#replace', 'url' => '/replace', 'verb' => 'POST'),
|
||||
array('name' => 'sms#retrieve_all_ids', 'url' => '/get/smsidlist', 'verb' => 'GET'),
|
||||
array('name' => 'sms#retrieve_all_ids_with_status', 'url' => '/get/smsidstate', 'verb' => 'GET'),
|
||||
array('name' => 'sms#retrieve_all_peers', 'url' => '/get/peerlist', 'verb' => 'GET'),
|
||||
array('name' => 'sms#get_conversation', 'url' => '/get/conversation', 'verb' => 'GET'),
|
||||
array('name' => 'sms#get_api_version', 'url' => '/get/apiversion', 'verb' => 'GET'),
|
||||
)));
|
||||
|
@ -57,6 +57,14 @@ class SmsController extends Controller {
|
||||
return new TemplateResponse($this->appName, 'main', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function getApiVersion () {
|
||||
return new JSONResponse(array("version" => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
@ -66,6 +74,15 @@ class SmsController extends Controller {
|
||||
return new JSONResponse(array("smslist" => $smsList));
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function retrieveAllIdsWithStatus () {
|
||||
$smsList = $this->smsMapper->getAllIdsWithStatus($this->userId);
|
||||
return new JSONResponse(array("smslist" => $smsList));
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
|
@ -51,6 +51,25 @@ class SmsMapper extends Mapper {
|
||||
return $smsList;
|
||||
}
|
||||
|
||||
public function getAllIdsWithStatus ($userId) {
|
||||
$query = \OCP\DB::prepare('SELECT sms_id, sms_type, sms_mailbox FROM ' .
|
||||
'*PREFIX*ocsms_smsdatas WHERE user_id = ?');
|
||||
$result = $query->execute(array($userId));
|
||||
|
||||
$smsList = array();
|
||||
while($row = $result->fetchRow()) {
|
||||
$mbox = SmsMapper::$mailboxNames[$row["sms_mailbox"]];
|
||||
if (!isset($smsList[$mbox])) {
|
||||
$smsList[$mbox] = array();
|
||||
}
|
||||
|
||||
if (!isset($smsList[$mbox][$row["sms_id"]])) {
|
||||
$smsList[$mbox][$row["sms_id"]] = $row["sms_type"];
|
||||
}
|
||||
}
|
||||
return $smsList;
|
||||
}
|
||||
|
||||
public function getAllPeersPhoneNumbers ($userId) {
|
||||
$query = \OCP\DB::prepare('SELECT sms_address FROM ' .
|
||||
'*PREFIX*ocsms_smsdatas WHERE user_id = ? AND sms_mailbox IN (?,?)');
|
||||
|
Loading…
x
Reference in New Issue
Block a user