Only clear known users when we had at least one phonebook entry

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-03-12 09:04:13 +01:00 committed by backportbot[bot]
parent 6e2f7ddc7a
commit 3efb2d2208
1 changed files with 3 additions and 3 deletions

View File

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