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 ;
1719
1820class 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