diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2016-01-31 00:47:08 +0300 |
---|---|---|
committer | Loic Blot <loic.blot@unix-experience.fr> | 2016-01-31 00:47:34 +0300 |
commit | 7fed10a26c6e41b3091b87af9cd26c1782b16eb5 (patch) | |
tree | df8d277d835340d3502ab01814f478442b51fd7e /controller | |
parent | a4ae53b19fd102cf0f9d8669f18c05ef159805a6 (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.php | 19 |
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")); + } + } |