mirror of
https://github.com/nerzhul/ocsms.git
synced 2025-06-07 16:06:15 +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:
parent
6868c1fa85
commit
580e4415e2
@ -221,6 +221,7 @@ class SmsController extends Controller {
|
|||||||
*/
|
*/
|
||||||
public function checkNewMessages($lastDate) {
|
public function checkNewMessages($lastDate) {
|
||||||
$phoneList = $this->smsMapper->getNewMessagesCountForAllPhonesNumbers($this->userId, $lastDate);
|
$phoneList = $this->smsMapper->getNewMessagesCountForAllPhonesNumbers($this->userId, $lastDate);
|
||||||
|
$formatedPhoneList = array();
|
||||||
$contactsSrc = $this->contactCache->getContacts();
|
$contactsSrc = $this->contactCache->getContacts();
|
||||||
$photosSrc = $this->contactCache->getContactPhotos();
|
$photosSrc = $this->contactCache->getContactPhotos();
|
||||||
$uidsSrc = $this->contactCache->getContactUids();
|
$uidsSrc = $this->contactCache->getContactUids();
|
||||||
@ -228,8 +229,12 @@ class SmsController extends Controller {
|
|||||||
$photos = array();
|
$photos = array();
|
||||||
$uids = array();
|
$uids = array();
|
||||||
|
|
||||||
|
// Cache country because of loops
|
||||||
|
$configuredCountry = $this->configMapper->getCountry();
|
||||||
|
|
||||||
foreach ($phoneList as $number => $ts) {
|
foreach ($phoneList as $number => $ts) {
|
||||||
$fmtPN = preg_replace("#[ ]#","", $number);
|
$fmtPN = PhoneNumberFormatter::format($configuredCountry, $number);
|
||||||
|
$formatedPhoneList[] = $fmtPN;
|
||||||
if (isset($contactsSrc[$fmtPN])) {
|
if (isset($contactsSrc[$fmtPN])) {
|
||||||
$contacts[$fmtPN] = $contactsSrc[$fmtPN];
|
$contacts[$fmtPN] = $contactsSrc[$fmtPN];
|
||||||
if (isset($uidsSrc[$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user