From 15f66e739cf59718d3232418b778fb5096ee8777 Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Tue, 8 Oct 2024 17:32:45 +0200 Subject: [PATCH] Make possible to disable sending mentions to users --- lib/AppConfig.php | 17 +++++++++++++++++ lib/Controller/EditorController.php | 9 ++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/AppConfig.php b/lib/AppConfig.php index 4528f9fe..d63a8447 100644 --- a/lib/AppConfig.php +++ b/lib/AppConfig.php @@ -225,6 +225,13 @@ class AppConfig { */ private $_verification = "verify_peer_off"; + /** + * The config for mentions + * + * @var string + */ + private $_mentions = "mentions"; + /** * The config key for the secret key in jwt * @@ -1153,6 +1160,16 @@ public function isUserAllowedToUse($userId = null) { return false; } + /** + * Check if sending mentions to users is enabled + * + * @return bool + */ + public function isMentionsEnabled() { + $value = $this->config->getAppValue($this->appName, $this->_mentions, "true"); + return in_array($value, ["on", "yes", "true"]); + } + /** * Save the document service verification setting to the application configuration * diff --git a/lib/Controller/EditorController.php b/lib/Controller/EditorController.php index ff4f9345..bd77f80f 100644 --- a/lib/Controller/EditorController.php +++ b/lib/Controller/EditorController.php @@ -363,12 +363,15 @@ public function createNew($name, $dir, $templateId = null) { public function users($fileId, $operationType = null) { $this->logger->debug("Search users", ["app" => $this->appName]); $result = []; - $currentUserGroups = []; if (!$this->config->isUserAllowedToUse()) { return $result; } + if (!$this->config->isMentionsEnabled()) { + return $result; + } + if (!$this->shareManager->allowEnumeration()) { return $result; } @@ -505,6 +508,10 @@ public function mention($fileId, $anchor, $comment, $emails) { return ["error" => $this->trans->t("Not permitted")]; } + if (!$this->config->isMentionsEnabled()) { + return ["error" => $this->trans->t("Mentions are not enabled")]; + } + if (empty($emails)) { return ["error" => $this->trans->t("Failed to send notification")]; }