mirror of
https://github.com/nextcloud/server.git
synced 2026-04-28 01:28:08 -04:00
fix(settings): Check all values first, then apply them
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
29fe9db52a
commit
b1d29c0b29
1 changed files with 8 additions and 3 deletions
|
|
@ -44,15 +44,20 @@ class AISettingsController extends Controller {
|
|||
continue;
|
||||
}
|
||||
try {
|
||||
$value = json_encode($settings[$key], flags: \JSON_THROW_ON_ERROR);
|
||||
$settings[$key] = json_encode($settings[$key], flags: \JSON_THROW_ON_ERROR);
|
||||
} catch (\JsonException) {
|
||||
return new DataResponse(['error' => "Setting value for '$key' must be JSON-compatible"], Http::STATUS_BAD_REQUEST);
|
||||
}
|
||||
$changed = $this->appConfig->setValueString('core', $key, $value, lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
|
||||
}
|
||||
foreach ($keys as $key) {
|
||||
if (!isset($settings[$key])) {
|
||||
continue;
|
||||
}
|
||||
$changed = $this->appConfig->setValueString('core', $key, $settings[$key], lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
|
||||
if ($changed) {
|
||||
$this->eventDispatcher->dispatchTyped(new CriticalActionPerformedEvent(
|
||||
'AI configuration was changed by user %s: %s was set to %s',
|
||||
[$this->userId, $key, $value]
|
||||
[$this->userId, $key, $settings[$key]]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue