Skip to content

Commit de5338f

Browse files
committed
Issue 719: Make it possible to create iTip messages for attendee on first upload
1 parent 90f3757 commit de5338f

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

lib/ITip/Broker.php

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,13 +248,25 @@ public function parseEvent($calendar, $userHref, $oldCalendar = null): array
248248

249249
if (in_array($eventInfo['organizer'], $userHref)) {
250250
return $this->parseEventForOrganizer($baseCalendar, $eventInfo, $oldEventInfo);
251-
} elseif ($oldCalendar) {
252-
// We need to figure out if the user is an attendee, but we're only
253-
// doing so if there's an oldCalendar, because we only want to
254-
// process updates, not creation of new events.
251+
} else {
252+
// We need to figure out if the user is an attendee. If
253+
// that is the case, we want to process that attendee if
254+
// there is also an oldcalendar or if some of the
255+
// instances of that attendee has partstat different from
256+
// NEEDS-ACTION. See
257+
// https://github.com/sabre-io/vobject/issues/719
255258
foreach ($eventInfo['attendees'] as $attendee) {
256259
if (in_array($attendee['href'], $userHref)) {
257-
return $this->parseEventForAttendee($baseCalendar, $eventInfo, $oldEventInfo, $attendee['href']);
260+
$isPartstatDefined = false;
261+
foreach ($attendee['instances'] as $instance) {
262+
if ($instance['partstat'] != 'NEEDS-ACTION') {
263+
$isPartstatDefined = true;
264+
break;
265+
}
266+
}
267+
if ($oldCalendar or $isPartstatDefined) {
268+
return $this->parseEventForAttendee($baseCalendar, $eventInfo, $oldEventInfo, $attendee['href']);
269+
}
258270
}
259271
}
260272
}

tests/VObject/ITip/BrokerAttendeeReplyTest.php

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,16 @@ class BrokerAttendeeReplyTest extends BrokerTester
66
{
77
public function testAccepted(): void
88
{
9-
$oldMessage = <<<ICS
10-
BEGIN:VCALENDAR
11-
VERSION:2.0
12-
BEGIN:VEVENT
13-
UID:foobar
14-
SUMMARY:B-day party
15-
SEQUENCE:1
16-
ORGANIZER;CN=Strunk:mailto:strunk@example.org
17-
ATTENDEE;CN=One:mailto:one@example.org
18-
DTSTART:20140716T120000Z
19-
END:VEVENT
20-
END:VCALENDAR
21-
ICS;
9+
10+
// If $oldMessage is not set, in some cases an iTip message
11+
// still needs to be generated; this happens when partstat
12+
// differs from NEEDS-ACTION. For example, this is relevant in
13+
// cases where a CalDAV client has received a calendar invite
14+
// in some way, and the user of the client accepts
15+
// participation before the upload. Also see
16+
// https://github.com/sabre-io/vobject/issues/719
17+
18+
$oldMessage = "";
2219

2320
$newMessage = <<<ICS
2421
BEGIN:VCALENDAR

0 commit comments

Comments
 (0)