Skip to content
Snippets Groups Projects
Commit f38248dc authored by Joas Schilling's avatar Joas Schilling Committed by backportbot[bot]
Browse files

Also check the default phone region when the number has no country code

parent 618a4848
No related branches found
No related tags found
No related merge requests found
......@@ -233,6 +233,7 @@ class UsersController extends AUserData {
/** @var IUser $user */
$user = $this->userSession->getUser();
$knownTo = $user->getUID();
$defaultPhoneRegion = $this->config->getSystemValueString('default_phone_region');
$normalizedNumberToKey = [];
foreach ($search as $key => $phoneNumbers) {
......@@ -245,6 +246,20 @@ class UsersController extends AUserData {
}
} catch (NumberParseException $e) {
}
if ($defaultPhoneRegion !== '' && $defaultPhoneRegion !== $location && strpos($phone, '0') === 0) {
// If the number has a leading zero (no country code),
// we also check the default phone region of the instance,
// when it's different to the user's given region.
try {
$phoneNumber = $phoneUtil->parse($phone, $defaultPhoneRegion);
if ($phoneNumber instanceof PhoneNumber && $phoneUtil->isValidNumber($phoneNumber)) {
$normalizedNumber = $phoneUtil->format($phoneNumber, PhoneNumberFormat::E164);
$normalizedNumberToKey[$normalizedNumber] = (string) $key;
}
} catch (NumberParseException $e) {
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment