#!perl
use Cassandane::Tiny;

sub test_calendarevent_get_privacy_ignore_override
    :min_version_3_7
{
    my ($self) = @_;
    my $jmap = $self->{jmap};
    my $caldav = $self->{caldav};

    xlog "PUT event where privacy differs in override";
    my $ical = <<'EOF';
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.10.4//EN
BEGIN:VEVENT
CREATED:20210923T034327Z
UID:6de280c9-edff-4019-8ebd-cfebc73f8201
DTSTAMP:20210923T034327Z
DTSTART;TZID=American/New_York:20210101T153000
DURATION:PT1H
RRULE:FREQ=DAILY;COUNT=3
SUMMARY:An Event
SEQUENCE:1
X-JMAP-PRIVACY:PRIVATE
END:VEVENT
BEGIN:VEVENT
CREATED:20210923T034327Z
UID:6de280c9-edff-4019-8ebd-cfebc73f8201
RECURRENCE-ID:20210102T153000
DTSTAMP:20210923T034327Z
DTSTART;TZID=American/New_York:20210102T153000
DURATION:PT1H
SUMMARY:An event exception
SEQUENCE:1
X-JMAP-PRIVACY:PUBLIC
END:VEVENT
END:VCALENDAR
EOF
    $caldav->Request('PUT',
        '/dav/calendars/user/cassandane/Default/test.ics',
        $ical, 'Content-Type' => 'text/calendar');

    xlog "Assert privacy of recurrence exception gets ignored";
    my $res = $jmap->CallMethods([
        ['CalendarEvent/get', {
            properties => ['privacy', 'recurrenceOverrides']
        }, 'R1'],
    ]);
    $self->assert_str_equals('private', $res->[0][1]{list}[0]{privacy});
    $self->assert_deep_equals({ title => 'An event exception'},
        $res->[0][1]{list}[0]{recurrenceOverrides}{'2021-01-02T15:30:00'});
}
