Merge pull request #26081 from nextcloud/backport/26080/stable21

[stable21] Only clear known users when we had at least one phonebook entry
This commit is contained in:
Roeland Jago Douma 2021-03-12 12:44:41 +01:00 committed by GitHub
commit 7f0f9fcd93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -239,9 +239,6 @@ class UsersController extends AUserData {
$user = $this->userSession->getUser();
$knownTo = $user->getUID();
// Cleanup all previous entries and only allow new matches
$this->knownUserService->deleteKnownTo($knownTo);
$normalizedNumberToKey = [];
foreach ($search as $key => $phoneNumbers) {
foreach ($phoneNumbers as $phone) {
@ -262,6 +259,9 @@ class UsersController extends AUserData {
return new DataResponse();
}
// Cleanup all previous entries and only allow new matches
$this->knownUserService->deleteKnownTo($knownTo);
$userMatches = $this->accountManager->searchUsers(IAccountManager::PROPERTY_PHONE, $phoneNumbers);
if (empty($userMatches)) {