Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ical_support: mark multiple standalone overrides as recurring #4557

Merged
merged 1 commit into from
Jul 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions cassandane/Cassandane/Cyrus/Caldav.pm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ use Net::DAVTalk::XMLParser;
use File::Basename;
use Data::Dumper;
use Text::VCardFast;
use Cwd qw(abs_path);

use lib '.';
use base qw(Cassandane::Cyrus::TestCase);
Expand Down Expand Up @@ -6031,4 +6032,44 @@ EOF
$self->assert_not_null($valarms[0]{properties}{uid});
}

sub test_freebusy_overrides
:min_version_3_9 :needs_component_httpd
{
my ($self) = @_;

my $CalDAV = $self->{caldav};

my $ical = <<EOF;
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.9.5//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
RECURRENCE-ID:20230909T160000Z
DTSTART:20230101T160000Z
DURATION:PT1H
UID:40ce7797-98ed-4185-a364-a95bb01ea2fe
SUMMARY:recur1
END:VEVENT
BEGIN:VEVENT
RECURRENCE-ID:20231231T160000Z
DTSTART:20231231T160000Z
DURATION:PT2H
UID:40ce7797-98ed-4185-a364-a95bb01ea2fe
SUMMARY:recur2
END:VEVENT
END:VCALENDAR
EOF

$CalDAV->Request('PUT', '/dav/calendars/user/cassandane/Default/test.ics',
$ical, 'Content-Type' => 'text/calendar');

my ($data, $errors) = $CalDAV->GetFreeBusy('Default');
$self->assert_str_equals('2023-01-01T16:00:00', $data->[0]{start});
$self->assert_str_equals('PT1H', $data->[0]{duration});
$self->assert_str_equals('2023-12-31T16:00:00', $data->[1]{start});
$self->assert_str_equals('PT2H', $data->[1]{duration});
$self->assert_num_equals(2, scalar @$data);
}

1;
9 changes: 9 additions & 0 deletions imap/ical_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,7 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical,
struct icalperiodtype span;
icalcomponent *comp = icalcomponent_get_first_component(ical, kind);
unsigned recurring = 0;
unsigned n_recurid = 0;

/* Initialize span to be nothing */
span.start = icaltime_from_timet_with_zone(caldav_eternity, 0, NULL);
Expand Down Expand Up @@ -1426,6 +1427,10 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical,
ptrarray_fini(&detached_rrules);
}

/* Count recurrence-ids */
if (icalcomponent_get_first_property(comp, ICAL_RECURRENCEID_PROPERTY))
if (n_recurid < UINT_MAX) n_recurid++;

/* Check our dtstart and dtend against span */
if (icaltime_compare(period.start, span.start) < 0)
memcpy(&span.start, &period.start, sizeof(struct icaltimetype));
Expand All @@ -1438,6 +1443,10 @@ icalrecurrenceset_get_utc_timespan(icalcomponent *ical,

} while ((comp = icalcomponent_get_next_component(ical, kind)));

/* There might be more than one recurrence override without main component */
if (!recurring && n_recurid >= 2)
recurring = 1;

if (is_recurring) *is_recurring = recurring;

return span;
Expand Down