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

Contact names are now get with peerlist

This commit is contained in:
Loic Blot
2014-10-05 08:54:44 +00:00
parent 4c9b653018
commit 71d6ed693b
3 changed files with 28 additions and 6 deletions
+17 -2
View File
@@ -71,8 +71,17 @@ class SmsController extends Controller {
*/
public function retrieveAllPeers () {
$phoneList = $this->smsMapper->getAllPeersPhoneNumbers($this->userId);
$contactsSrc = $this->app->getContacts();
$contacts = array();
$countPhone = count($phoneList);
for ($i=0; $i < $countPhone; $i++) {
if (isset($contactsSrc[$phoneList[$i]])) {
$contacts[$phoneList[$i]] = $contactsSrc[$phoneList[$i]];
}
}
// @ TODO: filter correctly
return new JSONResponse(array("phonelist" => $phoneList));
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts));
}
/**
@@ -81,8 +90,14 @@ class SmsController extends Controller {
*/
public function getConversation ($phoneNumber, $lastDate = 0) {
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate);
$contacts = $this->app->getContacts();
$contactName = "";
if (isset($contacts[$phoneNumber])) {
$contactName = $contacts[$phoneNumber];
}
// @ TODO: filter correctly
return new JSONResponse(array("conversation" => $messages, "contacts" => $this->app->getContacts()));
return new JSONResponse(array("conversation" => $messages, "contactName" => $contactName));
}
/**