Skip to content

Commit 096d366

Browse files
committed
fix: notify when the notification time is greater than or equal to interval
Signed-off-by: Vitor Mattos <[email protected]>
1 parent af4add8 commit 096d366

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/Service/ReminderService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private function isMaxReached(int $total, int $max): bool {
197197

198198
private function shouldNotifyAfterSomeDays(?\DateTime $date, \DateTime $now, int $maxDays): bool {
199199
$daysAfter = $date?->diff($now)?->days ?? 0;
200-
return $daysAfter > $maxDays;
200+
return $maxDays > 0 && $daysAfter >= $maxDays;
201201
}
202202

203203
protected function getNotificationsSummarized(array $notifications): array {

tests/php/Unit/Service/ReminderServiceTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ public static function providerWillNotify(): array {
166166
],
167167
'one notification, scheduled for yesterday, between = 1' => [
168168
[
169-
'first' => (clone $now)->modify('-1 day'),
170-
'last' => (clone $now)->modify('-1 day'),
169+
'first' => (clone $now)->modify('-1 day')->setTime(11, 0),
170+
'last' => (clone $now)->modify('-1 day')->setTime(11, 0),
171171
'total' => 1,
172172
],
173-
'now' => $now, 'daysBefore' => 1, 'daysBetween' => 1, 'max' => 5, false,
173+
'now' => $now, 'daysBefore' => 1, 'daysBetween' => 1, 'max' => 5, true,
174174
],
175175
'one notification, should send' => [
176176
[

0 commit comments

Comments
 (0)