Skip to content

Commit b3bc012

Browse files
committed
feat(settings): Log AI config changes to audit log
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
1 parent 728164c commit b3bc012

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/settings/lib/Controller/AISettingsController.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
use OCP\AppFramework\Controller;
1313
use OCP\AppFramework\Http\Attribute\AuthorizedAdminSetting;
1414
use OCP\AppFramework\Http\DataResponse;
15+
use OCP\EventDispatcher\IEventDispatcher;
1516
use OCP\IAppConfig;
1617
use OCP\IRequest;
18+
use OCP\Log\Audit\CriticalActionPerformedEvent;
1719

1820
class AISettingsController extends Controller {
1921

2022
public function __construct(
2123
$appName,
2224
IRequest $request,
25+
private string $userId,
2326
private IAppConfig $appConfig,
27+
private IEventDispatcher $eventDispatcher,
2428
) {
2529
parent::__construct($appName, $request);
2630
}
@@ -38,7 +42,13 @@ public function update($settings) {
3842
if (!isset($settings[$key])) {
3943
continue;
4044
}
41-
$this->appConfig->setValueString('core', $key, json_encode($settings[$key]), lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
45+
$changed = $this->appConfig->setValueString('core', $key, json_encode($settings[$key]), lazy: in_array($key, \OC\TaskProcessing\Manager::LAZY_CONFIG_KEYS, true));
46+
if ($changed) {
47+
$this->eventDispatcher->dispatchTyped(new CriticalActionPerformedEvent(
48+
'AI configuration was changed by user %s: %s was set to %s',
49+
[$this->userId, $key, json_encode($settings[$key])]
50+
));
51+
}
4252
}
4353

4454
return new DataResponse();

0 commit comments

Comments
 (0)