Skip to content

Commit

Permalink
caldav_alarm.c: don't skip other alarms if one has an absolate trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
ksmurchison committed Aug 7, 2023
1 parent ed02770 commit 9a5a061
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
29 changes: 24 additions & 5 deletions cassandane/Cassandane/Cyrus/CaldavAlarm.pm
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,12 @@ sub test_recurring_absolute_trigger
my $end = $enddt->strftime('%Y%m%dT%H%M%SZ');

# set the trigger to notify us at the start of the event
my $triggerdt = $startdt->clone();
$triggerdt->add(DateTime::Duration->new(seconds => 0 - $now->offset()));
my $trigger = $triggerdt->strftime('%Y%m%dT%H%M%SZ');
my $trigger = $startdt->strftime('%Y%m%dT%H%M%SZ');

# calculate start time for second instance
my $recuriddt = $startdt->clone();
$recuriddt->add(DateTime::Duration->new(days => 1));
my $recurid = $recuriddt->strftime('%Y%m%dT%H%M%SZ');

my $uuid = "574E2CD0-2D2A-4554-8B63-C7504481D3A9";
my $href = "$CalendarId/$uuid.ics";
Expand All @@ -657,13 +660,19 @@ SUMMARY:Simple
DTSTART:$start
DTSTAMP:20150806T234327Z
SEQUENCE:0
RRULE:FREQ=DAILY
RRULE:FREQ=DAILY;COUNT=3
BEGIN:VALARM
TRIGGER;VALUE=DATE-TIME:$trigger
ACTION:DISPLAY
SUMMARY: My alarm
DESCRIPTION:My alarm has triggered
END:VALARM
BEGIN:VALARM
TRIGGER:PT0S
ACTION:EMAIL
SUMMARY: My alarm
DESCRIPTION:My alarm has triggered
END:VALARM
END:VEVENT
END:VCALENDAR
EOF
Expand All @@ -673,13 +682,23 @@ EOF
# clean notification cache
$self->{instance}->getnotify();

# adjust now to UTC
$now->add(DateTime::Duration->new(seconds => $now->offset()));

$self->{instance}->run_command({ cyrus => 1 }, 'calalarmd', '-t' => $now->epoch() - 60 );

$self->assert_alarms();

# fire alarms for first instance
$self->{instance}->run_command({ cyrus => 1 }, 'calalarmd', '-t' => $now->epoch() + 60 );

$self->assert_alarms({summary => 'Simple', start => $start});
$self->assert_alarms({summary => 'Simple', start => $start, action => 'display'},
{summary => 'Simple', start => $start, action => 'email'});

# fire alarm for second instance
$self->{instance}->run_command({ cyrus => 1 }, 'calalarmd', '-t' => $now->epoch() + 86400 + 60 );

$self->assert_alarms({summary => 'Simple', start => $recurid, action => 'email'});
}

sub test_simple_reconstruct
Expand Down
12 changes: 6 additions & 6 deletions imap/caldav_alarm.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,12 @@ static int process_alarm_cb(icalcomponent *comp,
if (check <= data->last) {
continue;
}
else if (!is_duration &&
icaltime_compare(recurid, icalcomponent_get_dtstart(comp)) > 0) {
/* alarms with absolute triggers can only fire once */
syslog(LOG_DEBUG, "XXX absolute trigger - skipping recurrence");
continue;
}

if (check <= data->now && !data->dryrun) {
prop = icalcomponent_get_first_property(comp, ICAL_SUMMARY_PROPERTY);
Expand Down Expand Up @@ -631,12 +637,6 @@ static int process_alarm_cb(icalcomponent *comp,
data->nextcheck = next;
return 0;
}
else if (!is_duration) {
/* alarms with absolute triggers can only fire once,
so stop recurrence expansion */
syslog(LOG_DEBUG, "XXX absolute trigger - stop recurrence expansion");
return 0;
}
}

return 1; /* keep going */
Expand Down

0 comments on commit 9a5a061

Please sign in to comment.