feat(settings): Log AI config changes to audit log

Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
Marcel Klehr 2026-03-26 10:34:07 +01:00
parent 0cf140e903
commit 7fe3d1c6a0

View file

@ -12,15 +12,19 @@ use OCA\Settings\Settings\Admin\ArtificialIntelligence;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
use OCP\AppFramework\Http\DataResponse;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IAppConfig;
use OCP\IRequest;
use OCP\Log\Audit\CriticalActionPerformedEvent;
class AISettingsController extends Controller {
public function __construct(
$appName,
IRequest $request,
private string $userId,
private IAppConfig $appConfig,
private IEventDispatcher $eventDispatcher,
) {
parent::__construct($appName, $request);
}
@ -38,7 +42,13 @@ class AISettingsController extends Controller {
if (!isset($settings[$key])) {
continue;
}
$this->appConfig->setValueString('core', $key, json_encode($settings[$key]), lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
$changed = $this->appConfig->setValueString('core', $key, json_encode($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, json_encode($settings[$key])]
));
}
}
return new DataResponse();