|
36 | 36 | class MailQueueHandler { |
37 | 37 | public const CLI_EMAIL_BATCH_SIZE = 500; |
38 | 38 | public const WEB_EMAIL_BATCH_SIZE = 25; |
39 | | - /** Number of entries we want to list in the email */ |
40 | | - public const ENTRY_LIMIT = 200; |
| 39 | + public const MAIL_MAX_ITEMS_DEFAULT = 200; |
| 40 | + public const MAIL_MAX_ITEMS_CAP = 1000; |
41 | 41 |
|
42 | 42 | protected array $languages; |
43 | 43 | protected string $senderAddress; |
@@ -191,7 +191,7 @@ private function fetchAffectedUsers(IQueryBuilder $query): array { |
191 | 191 | * |
192 | 192 | * @return array [data of the first max. 200 entries, total number of entries] |
193 | 193 | */ |
194 | | - protected function getItemsForUser(string $affectedUser, int $maxTime, int $maxNumItems = self::ENTRY_LIMIT): array { |
| 194 | + protected function getItemsForUser(string $affectedUser, int $maxTime, int $maxNumItems = self::MAIL_MAX_ITEMS_DEFAULT): array { |
195 | 195 | $query = $this->connection->getQueryBuilder(); |
196 | 196 | $query->select('*') |
197 | 197 | ->from('activity_mq') |
@@ -282,7 +282,7 @@ protected function sendEmailToUser(string $userName, string $email, string $lang |
282 | 282 | return true; |
283 | 283 | } |
284 | 284 |
|
285 | | - [$mailData, $skippedCount] = $this->getItemsForUser($userName, $maxTime); |
| 285 | + [$mailData, $skippedCount] = $this->getItemsForUser($userName, $maxTime, $this->getMailMaxItems()); |
286 | 286 |
|
287 | 287 | $l = $this->getLanguage($lang); |
288 | 288 | $this->activityManager->setCurrentUserId($userName); |
@@ -416,4 +416,15 @@ protected function deleteSentItems(array $affectedUsers, int $maxTime): void { |
416 | 416 | ->andWhere($query->expr()->in('amq_affecteduser', $query->createNamedParameter($affectedUsers, IQueryBuilder::PARAM_STR_ARRAY), IQueryBuilder::PARAM_STR)); |
417 | 417 | $query->executeStatement(); |
418 | 418 | } |
| 419 | + |
| 420 | + private function getMailMaxItems(): int { |
| 421 | + $maxItems = $this->appConfig->getValueInt('activity', 'mail_max_items', self::MAIL_MAX_ITEMS_DEFAULT); |
| 422 | + if ($maxItems < 1) { |
| 423 | + return 1; |
| 424 | + } |
| 425 | + if ($maxItems > self::MAIL_MAX_ITEMS_CAP) { |
| 426 | + return self::MAIL_MAX_ITEMS_CAP; |
| 427 | + } |
| 428 | + return $maxItems; |
| 429 | + } |
419 | 430 | } |
0 commit comments