From bbcb75c589c9a2f52a4fa035fa76ec0a82e9eee8 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 15 Apr 2020 15:26:52 +0200 Subject: Require a distributed MemCache Signed-off-by: Joas Schilling --- lib/Controller/PageController.php | 3 +++ lib/Files/TemplateLoader.php | 3 +++ lib/PublicShare/TemplateLoader.php | 3 +++ lib/PublicShareAuth/TemplateLoader.php | 3 +++ lib/TInitialState.php | 11 +++++++++++ 5 files changed, 23 insertions(+) (limited to 'lib') diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index e13f3ff70..e7174b249 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -45,6 +45,7 @@ use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\NotPermittedException; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IInitialStateService; use OCP\ILogger; @@ -95,6 +96,7 @@ class PageController extends Controller { INotificationManager $notificationManager, IAppManager $appManager, IInitialStateService $initialStateService, + ICacheFactory $memcacheFactory, IRootFolder $rootFolder, Config $talkConfig, IConfig $serverConfig) { @@ -110,6 +112,7 @@ class PageController extends Controller { $this->notificationManager = $notificationManager; $this->appManager = $appManager; $this->initialStateService = $initialStateService; + $this->memcacheFactory = $memcacheFactory; $this->rootFolder = $rootFolder; $this->talkConfig = $talkConfig; $this->serverConfig = $serverConfig; diff --git a/lib/Files/TemplateLoader.php b/lib/Files/TemplateLoader.php index 7bc38b472..185e8cb13 100644 --- a/lib/Files/TemplateLoader.php +++ b/lib/Files/TemplateLoader.php @@ -32,6 +32,7 @@ use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventListener; use OCP\Files\IRootFolder; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IInitialStateService; use OCP\IUser; @@ -53,12 +54,14 @@ class TemplateLoader implements IEventListener { private $userSession; public function __construct(IInitialStateService $initialStateService, + ICacheFactory $memcacheFactory, Config $talkConfig, IConfig $serverConfig, IAppManager $appManager, IRootFolder $rootFolder, IUserSession $userSession) { $this->initialStateService = $initialStateService; + $this->memcacheFactory = $memcacheFactory; $this->talkConfig = $talkConfig; $this->serverConfig = $serverConfig; $this->appManager = $appManager; diff --git a/lib/PublicShare/TemplateLoader.php b/lib/PublicShare/TemplateLoader.php index e03bb3327..de5f55554 100644 --- a/lib/PublicShare/TemplateLoader.php +++ b/lib/PublicShare/TemplateLoader.php @@ -28,6 +28,7 @@ use OCA\Talk\Config; use OCA\Talk\TInitialState; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\FileInfo; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IInitialStateService; use OCP\Share\IShare; @@ -46,10 +47,12 @@ class TemplateLoader { use TInitialState; public function __construct(IInitialStateService $initialStateService, + ICacheFactory $memcacheFactory, Config $talkConfig, IConfig $serverConfig) { $this->initialStateService = $initialStateService; $this->talkConfig = $talkConfig; + $this->memcacheFactory = $memcacheFactory; $this->serverConfig = $serverConfig; } diff --git a/lib/PublicShareAuth/TemplateLoader.php b/lib/PublicShareAuth/TemplateLoader.php index 9aeccf565..1e7e0ab58 100644 --- a/lib/PublicShareAuth/TemplateLoader.php +++ b/lib/PublicShareAuth/TemplateLoader.php @@ -26,6 +26,7 @@ namespace OCA\Talk\PublicShareAuth; use OCA\Talk\Config; use OCA\Talk\TInitialState; use OCP\EventDispatcher\IEventDispatcher; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IInitialStateService; use OCP\Share\IShare; @@ -44,9 +45,11 @@ class TemplateLoader { use TInitialState; public function __construct(IInitialStateService $initialStateService, + ICacheFactory $memcacheFactory, Config $talkConfig, IConfig $serverConfig) { $this->initialStateService = $initialStateService; + $this->memcacheFactory = $memcacheFactory; $this->talkConfig = $talkConfig; $this->serverConfig = $serverConfig; } diff --git a/lib/TInitialState.php b/lib/TInitialState.php index 7452436de..6004f7538 100644 --- a/lib/TInitialState.php +++ b/lib/TInitialState.php @@ -23,10 +23,12 @@ declare(strict_types=1); namespace OCA\Talk; +use OC\HintException; use OC\User\NoUserException; use OCP\App\IAppManager; use OCP\Files\IRootFolder; use OCP\Files\NotPermittedException; +use OCP\ICacheFactory; use OCP\IConfig; use OCP\IInitialStateService; use OCP\IUser; @@ -40,6 +42,8 @@ trait TInitialState { protected $serverConfig; /** @var IInitialStateService */ protected $initialStateService; + /** @var ICacheFactory */ + protected $memcacheFactory; protected function publishInitialStateShared(): void { // Needed to enable the screensharing extension in Chromium < 72. @@ -50,6 +54,13 @@ trait TInitialState { $this->serverConfig->getAppValue('spreed', 'prefer_h264', 'no') === 'yes' ); + $signalingMode = $this->talkConfig->getSignalingMode(); + if ($signalingMode !== 'internal' && !$this->memcacheFactory->isAvailable()) { + throw new HintException( + 'External signaling is only supported with a distributed cache' + ); + } + $this->initialStateService->provideInitialState( 'talk', 'signaling_mode', $this->talkConfig->getSignalingMode() -- cgit v1.2.3