1010
1111use OCA \Notifications \Model \Settings ;
1212use OCA \Notifications \Model \SettingsMapper ;
13+ use OCP \AppFramework \Services \IAppConfig ;
1314use OCP \AppFramework \Utility \ITimeFactory ;
1415use OCP \BackgroundJob \TimedJob ;
1516use OCP \IDBConnection ;
@@ -22,6 +23,7 @@ public function __construct(
2223 private readonly IDBConnection $ connection ,
2324 private readonly IUserManager $ userManager ,
2425 private readonly SettingsMapper $ settingsMapper ,
26+ private readonly IAppConfig $ appConfig ,
2527 ) {
2628 parent ::__construct ($ time );
2729
@@ -31,6 +33,18 @@ public function __construct(
3133
3234 #[\Override]
3335 protected function run ($ argument ): void {
36+ $ update = $ this ->connection ->getQueryBuilder ();
37+ $ update ->update ('notifications_settings ' )
38+ ->set ('next_send_time ' , $ update ->createNamedParameter (1 ))
39+ ->where ($ update ->expr ()->eq ('next_send_time ' , $ update ->createNamedParameter (0 )))
40+ ->andWhere ($ update ->expr ()->neq ('batch_time ' , $ update ->createNamedParameter (Settings::EMAIL_SEND_OFF )));
41+
42+ $ batchTime = $ this ->appConfig ->getAppValueInt ('setting_batchtime ' );
43+ if ($ batchTime === Settings::EMAIL_SEND_OFF ) {
44+ $ update ->andWhere ($ update ->expr ()->neq ('batch_time ' , $ update ->createNamedParameter (Settings::EMAIL_SEND_DEFAULT )));
45+ }
46+ $ update ->executeStatement ();
47+
3448 $ query = $ this ->connection ->getQueryBuilder ();
3549 $ query ->select ('notification_id ' )
3650 ->from ('notifications ' )
@@ -42,7 +56,7 @@ protected function run($argument): void {
4256 $ result ->closeCursor ();
4357
4458 $ this ->userManager ->callForSeenUsers (function (IUser $ user ) use ($ maxId ): void {
45- if ($ user ->isEnabled ()) {
59+ if (! $ user ->isEnabled ()) {
4660 return ;
4761 }
4862
0 commit comments