diff options
author | Joas Schilling <coding@schilljs.com> | 2023-10-25 16:48:15 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-10-25 16:48:15 +0200 |
commit | 7bbf800a2ecb7b66e12f7acc84a3b8f0ddbb77b7 (patch) | |
tree | e31bd4589a76f9cf6578e21046e0c8d14846ffef | |
parent | 777241c1d7fad0c900699d6d5136652348e28cf1 (diff) |
fix(profile): Check if the user is allowed to create roomsfeat/674
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/Controller/PageController.php | 10 | ||||
-rw-r--r-- | lib/Profile/TalkAction.php | 17 |
2 files changed, 19 insertions, 8 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 79cf7b23c..de5b348fa 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -175,13 +175,17 @@ class PageController extends Controller { /** * @throws \InvalidArgumentException */ - protected function createPrivateRoom(string $targetUserId): Room { + protected function createContactRequestRoom(string $targetUserId): Room { $user = $this->userManager->get($targetUserId); if (!$user instanceof IUser) { throw new \InvalidArgumentException('user'); } - if ($this->profileManager->isProfileFieldVisible('talk', $user, null)) { + if ($this->talkConfig->isNotAllowedToCreateConversations($user)) { + throw new \InvalidArgumentException('config'); + } + + if (!$this->profileManager->isProfileFieldVisible('talk', $user, null)) { throw new \InvalidArgumentException('profile'); } @@ -218,7 +222,7 @@ class PageController extends Controller { } try { - $room = $this->createPrivateRoom($callUser); + $room = $this->createContactRequestRoom($callUser); } catch (\InvalidArgumentException) { $response = new TemplateResponse('core', '404-profile', [], TemplateResponse::RENDER_AS_GUEST); $response->throttle(['action' => 'callUser', 'callUser' => $callUser]); diff --git a/lib/Profile/TalkAction.php b/lib/Profile/TalkAction.php index b922a873c..c7a6dc8c6 100644 --- a/lib/Profile/TalkAction.php +++ b/lib/Profile/TalkAction.php @@ -79,16 +79,23 @@ class TalkAction implements ILinkAction { } public function getTarget(): ?string { - $visitingUser = $this->userSession->getUser(); - if ( - $this->config->isDisabledForUser($this->targetUser) - || ($visitingUser && $this->config->isDisabledForUser($visitingUser)) - ) { + if ($this->config->isDisabledForUser($this->targetUser)) { return null; } + + $visitingUser = $this->userSession->getUser(); if ($visitingUser === $this->targetUser) { return $this->urlGenerator->linkToRouteAbsolute('spreed.Page.index'); } + + if ($visitingUser && $this->config->isDisabledForUser($visitingUser)) { + return null; + } + + if (!$visitingUser && $this->config->isNotAllowedToCreateConversations($this->targetUser)) { + return null; + } + return $this->urlGenerator->linkToRouteAbsolute('spreed.Page.index') . '?callUser=' . $this->targetUser->getUID(); } } |