diff options
author | Joas Schilling <coding@schilljs.com> | 2023-01-23 20:38:17 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-01-23 20:39:23 +0100 |
commit | 016b780de0244ebba86a0f5d86dcc9545849cbfe (patch) | |
tree | 8eab3e3643b74e29f62dc530438141fe2102bf7c /lib | |
parent | c4c87ba5480cc28efcf793580f2bb6754aa1fa4c (diff) |
Only register Maps plugin when allowed to use Talk
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Maps/MapsPluginLoader.php | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/Maps/MapsPluginLoader.php b/lib/Maps/MapsPluginLoader.php index 6d133283b..a365b12d7 100644 --- a/lib/Maps/MapsPluginLoader.php +++ b/lib/Maps/MapsPluginLoader.php @@ -23,21 +23,31 @@ declare(strict_types=1); namespace OCA\Talk\Maps; +use OCA\Talk\Config; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; use OCP\IRequest; +use OCP\IUser; +use OCP\IUserSession; use OCP\Util; /** * @template-implements IEventListener<Event> */ class MapsPluginLoader implements IEventListener { - /** @var IRequest */ - private $request; + protected IRequest $request; + protected Config $talkConfig; + protected IUserSession $userSession; - public function __construct(IRequest $request) { + public function __construct( + IRequest $request, + Config $talkConfig, + IUserSession $userSession + ) { $this->request = $request; + $this->talkConfig = $talkConfig; + $this->userSession = $userSession; } public function handle(Event $event): void { @@ -49,6 +59,11 @@ class MapsPluginLoader implements IEventListener { return; } + $user = $this->userSession->getUser(); + if ($user instanceof IUser && $this->talkConfig->isDisabledForUser($user)) { + return; + } + if (strpos($this->request->getPathInfo(), '/apps/maps') === 0) { Util::addScript('spreed', 'talk-collections'); Util::addScript('spreed', 'talk-maps'); |