mirror of
https://github.com/nextcloud/server.git
synced 2026-04-24 07:39:23 -04:00
feat(settings): Log AI config changes to audit log
Signed-off-by: Marcel Klehr <mklehr@gmx.net>
This commit is contained in:
parent
0cf140e903
commit
7fe3d1c6a0
1 changed files with 11 additions and 1 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue