diff options
author | Joas Schilling <coding@schilljs.com> | 2021-03-31 08:45:32 +0200 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-03-31 08:30:56 +0000 |
commit | f38248dcd4366e4323e99be7b4ae84508cf4519d (patch) | |
tree | 82e46e9fdfdbb8219f1432dae735a0c5914a2f6e | |
parent | 618a48487f9fb6ff8541b169f5cf8f4e049f329e (diff) | |
download | nextcloud-server-f38248dcd4366e4323e99be7b4ae84508cf4519d.tar.gz nextcloud-server-f38248dcd4366e4323e99be7b4ae84508cf4519d.zip |
Also check the default phone region when the number has no country code
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | apps/provisioning_api/lib/Controller/UsersController.php | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php index f933cd4cd7f..f65744d9430 100644 --- a/apps/provisioning_api/lib/Controller/UsersController.php +++ b/apps/provisioning_api/lib/Controller/UsersController.php @@ -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) { + } + } } } |