mirror of
https://github.com/nextcloud/ocsms.git
synced 2026-08-11 16:32:55 +00:00
Added experimental merging for contacts with multiple numbers
This commit is contained in:
@@ -107,13 +107,37 @@ class SmsController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
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];
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
|
||||
if ($contactName != "") {
|
||||
$iContacts = $this->app->getInvertedContacts();
|
||||
$messages = array();
|
||||
if (isset($iContacts[$contactName])) {
|
||||
$ctPn = count($iContacts[$contactName]);
|
||||
for ($i=0; $i < $ctPn; $i++) {
|
||||
$messages = array_merge($messages,
|
||||
$this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $iContacts[$contactName][$i], $lastDate)
|
||||
);
|
||||
}
|
||||
}
|
||||
// This case mustn't be reached, but add it.
|
||||
else {
|
||||
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$messages = $this->smsMapper->getAllMessagesForPhoneNumber($this->userId, $phoneNumber, $lastDate);
|
||||
}
|
||||
|
||||
// Order by id (date)
|
||||
ksort($messages);
|
||||
|
||||
// @ TODO: filter correctly
|
||||
return new JSONResponse(array("conversation" => $messages, "contactName" => $contactName));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user