public function retrieveAllPeers()
{
$phoneList = $this->smsMapper->getLastMessageTimestampForAllPhonesNumbers($this->userId);
$contactsSrc = $this->contactCache->getContacts();
$contacts = array();
$photos = $this->contactCache->getContactPhotos();
// Cache country because of loops
$configuredCountry = $this->configMapper->getCountry();
foreach ($phoneList as $number => $ts) {
$fmtPN = PhoneNumberFormatter::format($configuredCountry, $number);
if (isset($contactsSrc[$number])) {
$contacts[$number] = $contactsSrc[$number];
} elseif (isset($contactsSrc[$fmtPN])) {
$contacts[$number] = $contactsSrc[$fmtPN];
} elseif (isset($contacts[$fmtPN])) {
$contacts[$number] = $fmtPN;
} else {
$contacts[$number] = $fmtPN;
}
}
$lastRead = $this->convStateMapper->getLast($this->userId);
$ocversion = \OCP\Util::getVersion();
$photoversion = 1;
if (version_compare($ocversion[0] . "." . $ocversion[1] . "." . $ocversion[2], "9.0.0", ">=")) {
$photoversion = 2;
}
return new JSONResponse(array("phonelist" => $phoneList, "contacts" => $contacts, "lastRead" => $lastRead, "photos" => $photos, "photo_version" => $photoversion));
}