diff options
author | Joas Schilling <coding@schilljs.com> | 2021-11-05 12:44:51 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-11-09 12:10:53 +0300 |
commit | fa036b2001e0505006b6f9fe24d3fc56af937b06 (patch) | |
tree | 7d102e103cf131ccf3ec8d5650b6a3de13e835e6 /core/Controller | |
parent | f4307ef4b16ffa1ea5a9e4697b57be36660a7953 (diff) |
Move common logic to share manager
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'core/Controller')
-rw-r--r-- | core/Controller/ProfilePageController.php | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/core/Controller/ProfilePageController.php b/core/Controller/ProfilePageController.php index 2a23b673be1..e4064370d9c 100644 --- a/core/Controller/ProfilePageController.php +++ b/core/Controller/ProfilePageController.php @@ -34,6 +34,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Services\IInitialState; use OCP\IGroupManager; use OCP\IRequest; +use OCP\IUser; use OCP\IUserManager; use OCP\IUserSession; use OCP\Share\IManager as IShareManager; @@ -108,12 +109,11 @@ class ProfilePageController extends Controller { TemplateResponse::RENDER_AS_GUEST, ); - if (!$this->userManager->userExists($targetUserId)) { + $targetUser = $this->userManager->get($targetUserId); + if (!$targetUser instanceof IUser) { return $profileNotFoundTemplate; } - $visitingUser = $this->userSession->getUser(); - $targetUser = $this->userManager->get($targetUserId); $targetAccount = $this->accountManager->getAccount($targetUser); if (!$this->isProfileEnabled($targetAccount)) { @@ -122,37 +122,14 @@ class ProfilePageController extends Controller { // Run user enumeration checks only if viewing another user's profile if ($targetUser !== $visitingUser) { - if ($this->shareManager->allowEnumerationFullMatch()) { - // Full id match is allowed - } elseif (!$this->shareManager->allowEnumeration()) { + if (!$this->shareManager->currentUserCanEnumerateTargetUser($visitingUser, $targetUser)) { return $profileNotFoundTemplate; - } else { - if ($this->shareManager->limitEnumerationToGroups() || $this->shareManager->limitEnumerationToPhone()) { - $targerUserGroupIds = $this->groupManager->getUserGroupIds($targetUser); - $visitingUserGroupIds = $this->groupManager->getUserGroupIds($visitingUser); - if ($this->shareManager->limitEnumerationToGroups() && $this->shareManager->limitEnumerationToPhone()) { - if ( - empty(array_intersect($targerUserGroupIds, $visitingUserGroupIds)) - && !$this->knownUserService->isKnownToUser($targetUser->getUID(), $visitingUser->getUID()) - ) { - return $profileNotFoundTemplate; - } - } elseif ($this->shareManager->limitEnumerationToGroups()) { - if (empty(array_intersect($targerUserGroupIds, $visitingUserGroupIds))) { - return $profileNotFoundTemplate; - } - } elseif ($this->shareManager->limitEnumerationToPhone()) { - if (!$this->knownUserService->isKnownToUser($targetUser->getUID(), $visitingUser->getUID())) { - return $profileNotFoundTemplate; - } - } - } } } $userStatuses = $this->userStatusManager->getUserStatuses([$targetUserId]); - $status = array_shift($userStatuses); - if (!empty($status)) { + $status = $userStatuses[$targetUserId] ?? null; + if ($status !== null) { $this->initialStateService->provideInitialState('status', [ 'icon' => $status->getIcon(), 'message' => $status->getMessage(), |