1
0
mirror of https://github.com/nextcloud/ocsms.git synced 2026-08-11 16:32:55 +00:00

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
This commit is contained in:
Loic Blot
2016-01-30 22:47:08 +01:00
parent a4ae53b19f
commit 7fed10a26c
6 changed files with 60 additions and 43 deletions
+17 -2
View File
@@ -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"));
}
}