diff --git a/src/Services/NewsletterDispatchService.php b/src/Services/NewsletterDispatchService.php index 569bfd0..8d8662f 100644 --- a/src/Services/NewsletterDispatchService.php +++ b/src/Services/NewsletterDispatchService.php @@ -76,19 +76,26 @@ final class NewsletterDispatchService continue; } - $log[] = $this->dispatchForTree($tree, $module, $now); + $log[] = $this->dispatchForTree($tree, $module, $now, $force); } return $log; } - private function dispatchForTree(Tree $tree, ModuleInterface $module, int $now): string + private function dispatchForTree(Tree $tree, ModuleInterface $module, int $now, bool $force): string { $include_anniversaries = Configuration::includeAnniversaries($tree); $lookahead = Configuration::lookaheadDays($tree); $historical_lookahead = Configuration::historicalLookaheadDays($tree); $current_month = date('Y-m', $now); - $include_historical = Configuration::lastHistoricalMonth($tree) !== $current_month; + + // Normally the historical section only appears on the first + // scheduled send of each calendar month. Forced sends (admin + // hitting "Send now" to preview the newsletter) always include + // it — otherwise re-clicking the button silently strips the + // section after the first run of the month. + $include_historical = $force + || Configuration::lastHistoricalMonth($tree) !== $current_month; $birthdays = $this->event_query_service->upcomingBirthdays($tree, $lookahead); $anniversaries = $include_anniversaries