fix: [periodic summary] Fetch just users from database that are enabled

pull/8600/head
Jakub Onderka 2022-09-21 12:47:36 +02:00
parent 9f21554d7a
commit 75a1e6e9da
2 changed files with 6 additions and 4 deletions

View File

@ -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

View File

@ -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,
],
]);
}