summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php2
-rw-r--r--apps/provisioning_api/lib/Listener/UserDeletedListener.php2
-rw-r--r--apps/settings/lib/Controller/UsersController.php2
-rw-r--r--lib/private/KnownUser/KnownUserMapper.php4
-rw-r--r--lib/private/KnownUser/KnownUserService.php39
5 files changed, 38 insertions, 11 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index d1dba3ea6ee..579f9ae522a 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -692,7 +692,7 @@ class UsersController extends AUserData {
$this->accountManager->updateUser($targetUser, $userAccount, true);
if ($key === IAccountManager::PROPERTY_PHONE) {
- $this->knownUserService->deleteKnownUser($targetUser->getUID());
+ $this->knownUserService->deleteByContactUserId($targetUser->getUID());
}
} catch (\InvalidArgumentException $e) {
throw new OCSException('Invalid ' . $e->getMessage(), 102);
diff --git a/apps/provisioning_api/lib/Listener/UserDeletedListener.php b/apps/provisioning_api/lib/Listener/UserDeletedListener.php
index f4fdb973080..1e021177bb4 100644
--- a/apps/provisioning_api/lib/Listener/UserDeletedListener.php
+++ b/apps/provisioning_api/lib/Listener/UserDeletedListener.php
@@ -49,6 +49,6 @@ class UserDeletedListener implements IEventListener {
$this->service->deleteKnownTo($user->getUID());
// Delete all entries that other users know this user
- $this->service->deleteKnownUser($user->getUID());
+ $this->service->deleteByContactUserId($user->getUID());
}
}
diff --git a/apps/settings/lib/Controller/UsersController.php b/apps/settings/lib/Controller/UsersController.php
index c4893b778fa..46de0b4cd96 100644
--- a/apps/settings/lib/Controller/UsersController.php
+++ b/apps/settings/lib/Controller/UsersController.php
@@ -413,7 +413,7 @@ class UsersController extends Controller {
try {
$data = $this->saveUserSettings($user, $data);
if ($beforeData[IAccountManager::PROPERTY_PHONE]['value'] !== $data[IAccountManager::PROPERTY_PHONE]['value']) {
- $this->knownUserService->deleteKnownUser($user->getUID());
+ $this->knownUserService->deleteByContactUserId($user->getUID());
}
return new DataResponse(
[
diff --git a/lib/private/KnownUser/KnownUserMapper.php b/lib/private/KnownUser/KnownUserMapper.php
index 1144e2fd212..e77e4752702 100644
--- a/lib/private/KnownUser/KnownUserMapper.php
+++ b/lib/private/KnownUser/KnownUserMapper.php
@@ -63,10 +63,12 @@ class KnownUserMapper extends QBMapper {
}
/**
+ * Returns all "known users" for the given "known to" user
+ *
* @param string $knownTo
* @return KnownUser[]
*/
- public function getKnownTo(string $knownTo): array {
+ public function getKnownUsers(string $knownTo): array {
$query = $this->db->getQueryBuilder();
$query->select('*')
->from($this->getTableName())
diff --git a/lib/private/KnownUser/KnownUserService.php b/lib/private/KnownUser/KnownUserService.php
index 3a97b967c3a..96af21c836f 100644
--- a/lib/private/KnownUser/KnownUserService.php
+++ b/lib/private/KnownUser/KnownUserService.php
@@ -33,30 +33,55 @@ class KnownUserService {
$this->mapper = $mapper;
}
+ /**
+ * Delete all matches where the given user is the owner of the phonebook
+ *
+ * @param string $knownTo
+ * @return int Number of deleted matches
+ */
public function deleteKnownTo(string $knownTo): int {
return $this->mapper->deleteKnownTo($knownTo);
}
- public function deleteKnownUser(string $knownUser): int {
- return $this->mapper->deleteKnownUser($knownUser);
+ /**
+ * Delete all matches where the given user is the one in the phonebook
+ *
+ * @param string $contactUserId
+ * @return int Number of deleted matches
+ */
+ public function deleteByContactUserId(string $contactUserId): int {
+ return $this->mapper->deleteKnownUser($contactUserId);
}
- public function storeIsKnownToUser(string $knownTo, string $knownUser): void {
+ /**
+ * Store a match because $knownTo has $contactUserId in his phonebook
+ *
+ * @param string $knownTo User id of the owner of the phonebook
+ * @param string $contactUserId User id of the contact in the phonebook
+ */
+ public function storeIsKnownToUser(string $knownTo, string $contactUserId): void {
$entity = new KnownUser();
$entity->setKnownTo($knownTo);
- $entity->setKnownUser($knownUser);
+ $entity->setKnownUser($contactUserId);
$this->mapper->insert($entity);
}
- public function isKnownToUser(string $knownTo, string $user): bool {
+ /**
+ * Check if $contactUserId is in the phonebook of $knownTo
+ *
+ * @param string $knownTo User id of the owner of the phonebook
+ * @param string $contactUserId User id of the contact in the phonebook
+ * @return bool
+ */
+ public function isKnownToUser(string $knownTo, string $contactUserId): bool {
if (!isset($this->knownUsers[$knownTo])) {
- $entities = $this->mapper->getKnownTo($knownTo);
+ $entities = $this->mapper->getKnownUsers($knownTo);
$this->knownUsers[$knownTo] = [];
foreach ($entities as $entity) {
$this->knownUsers[$knownTo][$entity->getKnownUser()] = true;
}
}
- return isset($this->knownUsers[$knownTo][$user]);
+ return isset($this->knownUsers[$knownTo][$contactUserId]);
}
}