Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/ocsms.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-01-31 00:47:08 +0300
committerLoic Blot <loic.blot@unix-experience.fr>2016-01-31 00:47:34 +0300
commit7fed10a26c6e41b3091b87af9cd26c1782b16eb5 (patch)
treedf8d277d835340d3502ab01814f478442b51fd7e /controller
parenta4ae53b19fd102cf0f9d8669f18c05ef159805a6 (diff)
Message limit & other improvements
* Implement message limit permitting to limit number of message shown when loading a conversation * Reformat message date properly using angular JS instead of our own date parser * replace /get/country call with /get/settings to retrieve all settings This fixes issue #90
Diffstat (limited to 'controller')
-rw-r--r--controller/smscontroller.php19
1 files changed, 17 insertions, 2 deletions
diff --git a/controller/smscontroller.php b/controller/smscontroller.php
index 53374e8..304587c 100644
--- a/controller/smscontroller.php
+++ b/controller/smscontroller.php
@@ -137,6 +137,9 @@ class SmsController extends Controller {
}
// Order by id (date)
ksort($messages);
+ $msgLimit = $this->configMapper->getMessageLimit();
+ // Only load the last 500 messages
+ $messages = array_slice($messages, -$msgLimit, $msgLimit, true);
// Set the last read message for the conversation (all phone numbers)
if (count($messages) > 0) {
@@ -239,11 +242,23 @@ class SmsController extends Controller {
/**
* @NoAdminRequired
*/
- function getCountry() {
+ function getSettings() {
$country = $this->configMapper->getKey("country");
if ($country === false) {
return new JSONResponse(array("status" => false));
}
- return new JSONResponse(array("status" => true, "country" => $country));
+ $message_limit = $this->configMapper->getKey("message_limit");
+ return new JSONResponse(array("status" => true,
+ "country" => $country,
+ "message_limit" => $message_limit));
}
+
+ /**
+ * @NoAdminRequired
+ */
+ function setMessageLimit($limit) {
+ $this->configMapper->set("message_limit", $limit);
+ return new JSONResponse(array("status" => true, "msg" => "OK"));
+ }
+
}