Skip to content

Commit

Permalink
Make possible to disable sending mentions to users
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubOnderka committed Oct 8, 2024
1 parent cde1e2e commit 15f66e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
17 changes: 17 additions & 0 deletions lib/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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
*
Expand Down
9 changes: 8 additions & 1 deletion lib/Controller/EditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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")];
}
Expand Down

0 comments on commit 15f66e7

Please sign in to comment.