Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-10-08 12:40:00 +0300
committerJoas Schilling <coding@schilljs.com>2019-10-21 16:12:19 +0300
commit5ab5ff47b8ec489739de70357a865462a4d6fd4c (patch)
tree01568996b128c3a256c5ec5444c6eca7f0755efe /lib
parentec15df2bc3884cf3fab0a0d9cc206c94a0aedcfd (diff)
Add a setting to disable files and public sharing integration
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/FilesIntegrationController.php14
-rw-r--r--lib/Files/TemplateLoader.php7
-rw-r--r--lib/PublicShare/TemplateLoader.php13
-rw-r--r--lib/Settings/Admin/GeneralSettings.php2
4 files changed, 31 insertions, 5 deletions
diff --git a/lib/Controller/FilesIntegrationController.php b/lib/Controller/FilesIntegrationController.php
index 491709ef2..acfbda5e5 100644
--- a/lib/Controller/FilesIntegrationController.php
+++ b/lib/Controller/FilesIntegrationController.php
@@ -34,6 +34,7 @@ use OCP\AppFramework\OCS\OCSNotFoundException;
use OCP\AppFramework\OCSController;
use OCP\Files\FileInfo;
use OCP\Files\NotFoundException;
+use OCP\IConfig;
use OCP\IL10N;
use OCP\IRequest;
use OCP\ISession;
@@ -57,6 +58,8 @@ class FilesIntegrationController extends OCSController {
private $talkSession;
/** @var Util */
private $util;
+ /** @var IConfig */
+ private $config;
/** @var IL10N */
private $l;
@@ -69,6 +72,7 @@ class FilesIntegrationController extends OCSController {
IUserSession $userSession,
TalkSession $talkSession,
Util $util,
+ IConfig $config,
IL10N $l10n
) {
parent::__construct($appName, $request);
@@ -78,6 +82,7 @@ class FilesIntegrationController extends OCSController {
$this->userSession = $userSession;
$this->talkSession = $talkSession;
$this->util = $util;
+ $this->config = $config;
$this->l = $l10n;
}
@@ -112,6 +117,10 @@ class FilesIntegrationController extends OCSController {
* @throws OCSNotFoundException
*/
public function getRoomByFileId(string $fileId): DataResponse {
+ if ($this->config->getAppValue('spreed', 'conversations_files', '1') !== '1') {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+
$currentUser = $this->userSession->getUser();
if (!$currentUser instanceof IUser) {
throw new OCSException($this->l->t('File is not shared, or shared but not with the user'), Http::STATUS_UNAUTHORIZED);
@@ -180,6 +189,11 @@ class FilesIntegrationController extends OCSController {
* or "404 Not found" if the given share token was invalid.
*/
public function getRoomByShareToken(string $shareToken): DataResponse {
+ if ($this->config->getAppValue('spreed', 'conversations_files', '1') !== '1' ||
+ $this->config->getAppValue('spreed', 'conversations_files_public_shares', '1') !== '1') {
+ return new DataResponse([], Http::STATUS_BAD_REQUEST);
+ }
+
try {
$share = $this->shareManager->getShareByToken($shareToken);
if ($share->getPassword() !== null) {
diff --git a/lib/Files/TemplateLoader.php b/lib/Files/TemplateLoader.php
index a8f41d037..83cba79a6 100644
--- a/lib/Files/TemplateLoader.php
+++ b/lib/Files/TemplateLoader.php
@@ -32,7 +32,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class TemplateLoader {
public static function register(EventDispatcherInterface $dispatcher): void {
- $dispatcher->addListener('OCA\Files::loadAdditionalScripts', function() {
+ $dispatcher->addListener('OCA\Files::loadAdditionalScripts', static function() {
self::loadTalkSidebarForFilesApp();
});
}
@@ -44,6 +44,11 @@ class TemplateLoader {
* Files app.
*/
public static function loadTalkSidebarForFilesApp(): void {
+ $config = \OC::$server->getConfig();
+ if ($config->getAppValue('spreed', 'conversations_files', '1') !== '1') {
+ return;
+ }
+
Util::addStyle('spreed', 'merged-files');
Util::addScript('spreed', 'merged-files');
}
diff --git a/lib/PublicShare/TemplateLoader.php b/lib/PublicShare/TemplateLoader.php
index 1d37eb7c7..19e3a5590 100644
--- a/lib/PublicShare/TemplateLoader.php
+++ b/lib/PublicShare/TemplateLoader.php
@@ -37,10 +37,9 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class TemplateLoader {
public static function register(EventDispatcherInterface $dispatcher): void {
- $listener = function() {
+ $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', static function() {
self::loadTalkSidebarUi();
- };
- $dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', $listener);
+ });
}
/**
@@ -49,7 +48,13 @@ class TemplateLoader {
* This method should be called when loading additional scripts for the
* public share page of the server.
*/
- public static function loadTalkSidebarUi() {
+ public static function loadTalkSidebarUi(): void {
+ $config = \OC::$server->getConfig();
+ if ($config->getAppValue('spreed', 'conversations_files', '1') !== '1' ||
+ $config->getAppValue('spreed', 'conversations_files_public_shares', '1') !== '1') {
+ return;
+ }
+
Util::addStyle('spreed', 'merged-public-share');
Util::addScript('spreed', 'merged-public-share');
}
diff --git a/lib/Settings/Admin/GeneralSettings.php b/lib/Settings/Admin/GeneralSettings.php
index e6d2d2f2b..a4ff05ca8 100644
--- a/lib/Settings/Admin/GeneralSettings.php
+++ b/lib/Settings/Admin/GeneralSettings.php
@@ -47,6 +47,8 @@ class GeneralSettings implements ISettings {
*/
public function getForm(): TemplateResponse {
$this->initialStateService->provideInitialState('talk', 'start_calls', (int) $this->config->getAppValue('spreed', 'start_calls', '0'));
+ $this->initialStateService->provideInitialState('talk', 'conversations_files', (int) $this->config->getAppValue('spreed', 'conversations_files', '1'));
+ $this->initialStateService->provideInitialState('talk', 'conversations_files_public_shares', (int) $this->config->getAppValue('spreed', 'conversations_files_public_shares', '1'));
return new TemplateResponse('spreed', 'settings/admin/general-settings', [], '');
}