diff options
author | Greg Ross <greg@toolstack.com> | 2018-07-02 09:33:13 +0300 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-07-02 09:33:13 +0300 |
commit | 580e4415e24f3a7496f930aac9a2386148a56ebf (patch) | |
tree | c3cbe981613277157b4b4532d92f346ec19aca89 /controller | |
parent | 6868c1fa85a012db6501ca655472f385bce913aa (diff) |
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.
Diffstat (limited to 'controller')
-rw-r--r-- | controller/smscontroller.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/controller/smscontroller.php b/controller/smscontroller.php index 5b3acdc..b99093f 100644 --- a/controller/smscontroller.php +++ b/controller/smscontroller.php @@ -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)); } /** |