Skip to content

Commit

Permalink
feat(lexicon): enforce default userconfig
Browse files Browse the repository at this point in the history
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Dec 16, 2024
1 parent fd69431 commit 1ce2155
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/private/Config/UserConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -1850,14 +1850,15 @@ private function matchAndApplyLexiconDefinition(
$this->logger->notice('User config key ' . $app . '/' . $key . ' is set as deprecated.');
}

if ($this->hasKey($userId, $app, $key, $lazy)) {
$enforcedValue = $this->config->getSystemValue('lexicon.default.userconfig.enforced', [])[$app][$key] ?? false;
if (!$enforcedValue && $this->hasKey($userId, $app, $key, $lazy)) {
return true; // if key exists there should be no need to extract default
}

// default from Lexicon got priority but it can still be overwritten by admin
$default = $this->getSystemDefault($app, $configValue) ?? $configValue->getDefault() ?? $default;

return true;
return !$enforcedValue; // returning false will make get() returning $default and set() not changing value in database
}

/**
Expand Down

0 comments on commit 1ce2155

Please sign in to comment.