1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 07:56:23 +00:00

Fix the unread state (#251)

The checkNewMessages method was using an old regex phone number formatter and not returning the phone numbers in a formated fashion back to the client side.
This commit is contained in:
Greg Ross 2018-07-02 02:33:13 -04:00 committed by Loïc Blot
parent 6868c1fa85
commit 580e4415e2

View File

@ -221,6 +221,7 @@ class SmsController extends Controller {
*/
public function checkNewMessages($lastDate) {
$phoneList = $this->smsMapper->getNewMessagesCountForAllPhonesNumbers($this->userId, $lastDate);
$formatedPhoneList = array();
$contactsSrc = $this->contactCache->getContacts();
$photosSrc = $this->contactCache->getContactPhotos();
$uidsSrc = $this->contactCache->getContactUids();
@ -228,8 +229,12 @@ class SmsController extends Controller {
$photos = array();
$uids = array();
// Cache country because of loops
$configuredCountry = $this->configMapper->getCountry();
foreach ($phoneList as $number => $ts) {
$fmtPN = preg_replace("#[ ]#","", $number);
$fmtPN = PhoneNumberFormatter::format($configuredCountry, $number);
$formatedPhoneList[] = $fmtPN;
if (isset($contactsSrc[$fmtPN])) {
$contacts[$fmtPN] = $contactsSrc[$fmtPN];
if (isset($uidsSrc[$fmtPN])) {
@ -242,7 +247,7 @@ class SmsController extends Controller {
}
}
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "photos" => $photos, "uids" => $uids));
return new JSONResponse(array("phonelist" => $formatedPhoneList, "contacts" => $contacts, "photos" => $photos, "uids" => $uids));
}
/**