1212use OCP \AppFramework \Controller ;
1313use OCP \AppFramework \Http \Attribute \AuthorizedAdminSetting ;
1414use OCP \AppFramework \Http \DataResponse ;
15+ use OCP \EventDispatcher \IEventDispatcher ;
1516use OCP \IAppConfig ;
1617use OCP \IRequest ;
18+ use OCP \Log \Audit \CriticalActionPerformedEvent ;
19+ use function OCP \Log \logger ;
1720
1821class AISettingsController extends Controller {
1922
2023 public function __construct (
2124 $ appName ,
2225 IRequest $ request ,
26+ private string $ userId ,
2327 private IAppConfig $ appConfig ,
28+ private IEventDispatcher $ eventDispatcher ,
2429 ) {
2530 parent ::__construct ($ appName , $ request );
2631 }
@@ -38,7 +43,13 @@ public function update($settings) {
3843 if (!isset ($ settings [$ key ])) {
3944 continue ;
4045 }
41- $ this ->appConfig ->setValueString ('core ' , $ key , json_encode ($ settings [$ key ]), lazy: in_array ($ key , \OC \TaskProcessing \Manager::LAZY_CONFIG_KEYS , true ));
46+ $ changed = $ this ->appConfig ->setValueString ('core ' , $ key , json_encode ($ settings [$ key ]), lazy: in_array ($ key , \OC \TaskProcessing \Manager::LAZY_CONFIG_KEYS , true ));
47+ if ($ changed ) {
48+ $ this ->eventDispatcher ->dispatchTyped (new CriticalActionPerformedEvent (
49+ 'AI configuration was changed by user %s: %s was set to %s ' ,
50+ [$ this ->userId , $ key , json_encode ($ settings [$ key ])]
51+ ));
52+ }
4253 }
4354
4455 return new DataResponse ();
0 commit comments