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,14 @@ 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+ logger ('core ' )->error ('AI CONFIG CHANGED ' .var_export ($ changed , true ));
48+ if ($ changed ) {
49+ $ this ->eventDispatcher ->dispatchTyped (new CriticalActionPerformedEvent (
50+ 'AI configuration was changed by user %s: %s was set to %s ' ,
51+ [$ this ->userId , $ key , json_encode ($ settings [$ key ])]
52+ ));
53+ }
4254 }
4355
4456 return new DataResponse ();
0 commit comments