Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make possible to disable sending mentions to users #1030

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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