diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2023-01-24 12:10:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 12:10:12 +0100 |
commit | 63084450dbed86c7c8787ca7985573ba5c5ff6ee (patch) | |
tree | cb444956adf49e6a25a80c5003ff078253aef011 /lib | |
parent | 4fd0950c100da80be732a058207ed0d578cfeacf (diff) | |
parent | 016b780de0244ebba86a0f5d86dcc9545849cbfe (diff) |
Merge pull request #8587 from nextcloud/bugfix/noid/only-register-maps-interaction-when-allowed
Only register Maps plugin when allowed to use Talk
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'); |