From 75a1e6e9daf8a25986d89b945fd52ee49f0f774a Mon Sep 17 00:00:00 2001 From: Jakub Onderka Date: Wed, 21 Sep 2022 12:47:36 +0200 Subject: [PATCH] fix: [periodic summary] Fetch just users from database that are enabled --- app/Console/Command/ServerShell.php | 3 +-- app/Model/User.php | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Console/Command/ServerShell.php b/app/Console/Command/ServerShell.php index 81d868b5c..c0ea85425 100644 --- a/app/Console/Command/ServerShell.php +++ b/app/Console/Command/ServerShell.php @@ -598,7 +598,6 @@ class ServerShell extends AppShell public function sendPeriodicSummaryToUsers() { - $this->ConfigLoad->execute(); $periods = $this->__getPeriodsForToday(); $start_time = time(); echo __n('Started periodic summary generation for the %s period', 'Started periodic summary generation for periods: %s', count($periods), implode(', ', $periods)) . PHP_EOL; @@ -611,7 +610,7 @@ class ServerShell extends AppShell $this->User->sendEmail($user, $emailTemplate, false, null); } } - echo __('All reports sent. Task took %s secondes', time() - $start_time) . PHP_EOL; + echo __('All reports sent. Task took %s seconds', time() - $start_time) . PHP_EOL; } private function __getPeriodsForToday(): array diff --git a/app/Model/User.php b/app/Model/User.php index ec9d33f18..e486575bc 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -830,7 +830,7 @@ class User extends AppModel * @param array $user * @param SendEmailTemplate|string $body * @param string|false $bodyNoEnc - * @param string $subject + * @param string|null $subject * @param array|false $replyToUser * @return bool * @throws Crypt_GPG_BadPassphraseException @@ -1741,7 +1741,10 @@ class User extends AppModel { return $this->find('all', [ 'recursive' => -1, - 'conditions' => ["notification_$period" => true], + 'conditions' => [ + "notification_$period" => true, + 'disabled' => false, + ], ]); }