mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-07-16 22:46:49 +00:00
Code cleanup + some PHPDoc
This commit is contained in:
parent
339f76cf01
commit
f05d5562b8
@ -74,9 +74,12 @@ class ApiController extends Controller {
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @param $smsCount
|
||||
* @param $smsDatas
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function push ($smsCount, $smsDatas) {
|
||||
if ($this->checkPushStructure($smsCount, $smsDatas, true) === false) {
|
||||
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
|
||||
return new JSONResponse(array("status" => false, "msg" => $this->errorMsg));
|
||||
}
|
||||
|
||||
@ -86,9 +89,12 @@ class ApiController extends Controller {
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @param $smsCount
|
||||
* @param $smsDatas
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function replace($smsCount, $smsDatas) {
|
||||
if ($this->checkPushStructure($smsCount, $smsDatas, true) === false) {
|
||||
if ($this->checkPushStructure($smsCount, $smsDatas) === false) {
|
||||
return new JSONResponse(array("status" => false, "msg" => $this->errorMsg));
|
||||
}
|
||||
|
||||
@ -96,6 +102,11 @@ class ApiController extends Controller {
|
||||
return new JSONResponse(array("status" => true, "msg" => "OK"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $smsCount
|
||||
* @param $smsDatas
|
||||
* @return bool
|
||||
*/
|
||||
private function checkPushStructure ($smsCount, $smsDatas) {
|
||||
if ($smsCount != count($smsDatas)) {
|
||||
$this->errorMsg = "Error: sms count invalid";
|
||||
@ -163,6 +174,9 @@ class ApiController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* APIv2
|
||||
* @param $start
|
||||
* @param $limit
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function fetchMessages($start, $limit) {
|
||||
if (!is_numeric($start) || !is_numeric($limit) || $start < 0 || $limit <= 0) {
|
||||
@ -183,6 +197,10 @@ class ApiController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
*
|
||||
* APIv2
|
||||
* @param $phoneNumber
|
||||
* @param $start
|
||||
* @param $limit
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function fetchMessagesForNumber($phoneNumber, $start, $limit) {
|
||||
if (!is_numeric($start) || !is_numeric($limit) || $start < 0 || $limit <= 0) {
|
||||
|
@ -52,6 +52,8 @@ class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @param $country
|
||||
* @return JSONResponse
|
||||
*/
|
||||
function setCountry($country) {
|
||||
if (!array_key_exists($country, CountryCodes::$codes)) {
|
||||
@ -63,6 +65,8 @@ class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @param $limit
|
||||
* @return JSONResponse
|
||||
*/
|
||||
function setMessageLimit($limit) {
|
||||
$this->configMapper->set("message_limit", $limit);
|
||||
@ -71,6 +75,8 @@ class SettingsController extends Controller {
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @param $notification
|
||||
* @return JSONResponse
|
||||
*/
|
||||
function setNotificationState($notification) {
|
||||
if (!is_numeric($notification) || $notification < 0 || $notification > 2) {
|
||||
|
@ -24,7 +24,6 @@ use \OCA\OcSms\Db\ConfigMapper;
|
||||
use \OCA\OcSms\Db\SmsMapper;
|
||||
|
||||
use \OCA\OcSms\Lib\ContactCache;
|
||||
use \OCA\OcSms\Lib\CountryCodes;
|
||||
use \OCA\OcSms\Lib\PhoneNumberFormatter;
|
||||
|
||||
class SmsController extends Controller {
|
||||
@ -33,7 +32,6 @@ class SmsController extends Controller {
|
||||
private $userId;
|
||||
private $configMapper;
|
||||
private $smsMapper;
|
||||
private $errorMsg;
|
||||
private $urlGenerator;
|
||||
private $contactCache;
|
||||
|
||||
@ -84,7 +82,6 @@ class SmsController extends Controller {
|
||||
// Cache country because of loops
|
||||
$configuredCountry = $this->configMapper->getCountry();
|
||||
|
||||
$countPhone = count($phoneList);
|
||||
foreach ($phoneList as $number => $ts) {
|
||||
$fmtPN = PhoneNumberFormatter::format($configuredCountry, $number);
|
||||
if (isset($contactsSrc[$number])) {
|
||||
@ -110,6 +107,9 @@ class SmsController extends Controller {
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @param $phoneNumber
|
||||
* @param int $lastDate
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function getConversation ($phoneNumber, $lastDate = 0) {
|
||||
$contacts = $this->contactCache->getContacts();
|
||||
@ -163,6 +163,8 @@ class SmsController extends Controller {
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @param $contact
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function deleteConversation ($contact) {
|
||||
$contacts = $this->contactCache->getContacts();
|
||||
@ -193,6 +195,8 @@ class SmsController extends Controller {
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @param $lastDate
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function checkNewMessages($lastDate) {
|
||||
$phoneList = $this->smsMapper->getNewMessagesCountForAllPhonesNumbers($this->userId, $lastDate);
|
||||
@ -201,7 +205,6 @@ class SmsController extends Controller {
|
||||
$contacts = array();
|
||||
$photos = array();
|
||||
|
||||
$countPhone = count($phoneList);
|
||||
foreach ($phoneList as $number => $ts) {
|
||||
$fmtPN = preg_replace("#[ ]#","/", $number);
|
||||
if (isset($contactsSrc[$fmtPN])) {
|
||||
@ -225,6 +228,9 @@ class SmsController extends Controller {
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
* @param $messageId
|
||||
* @param $phoneNumber
|
||||
* @return JSONResponse
|
||||
*/
|
||||
public function deleteMessage ($messageId, $phoneNumber) {
|
||||
if (!preg_match('#^[0-9]+$#',$messageId)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user