Skip to content

Commit

Permalink
Merge pull request #669 from SebastianKrupinski/fix-status-cancelled
Browse files Browse the repository at this point in the history
fix: check if event status was changed to cancelled and generate appr…
  • Loading branch information
phil-davis authored Oct 14, 2024
2 parents cba15f0 + a2f05dd commit 28e191b
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ITip/Broker.php
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,11 @@ protected function parseEventForOrganizer(VCalendar $calendar, array $eventInfo,
$icalMsg->add(clone $timezone);
}

if (!$attendee['newInstances']) {
// If there are no instances the attendee is a part of, it
// means the attendee was removed and we need to send him a
// CANCEL.
if (!$attendee['newInstances'] || 'CANCELLED' === $eventInfo['status']) {
// If there are no instances the attendee is a part of, it means
// the attendee was removed and we need to send them a CANCEL message.
// Also If the meeting STATUS property was changed to CANCELLED
// we need to send the attendee a CANCEL message.
$message->method = 'CANCEL';

$icalMsg->METHOD = $message->method;
Expand Down
62 changes: 62 additions & 0 deletions tests/VObject/ITip/BrokerUpdateEventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -814,4 +814,66 @@ public function testInviteChangeExdateOrder(): void

$this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk@example.org');
}

public function testInviteStatusCancelled(): void
{
$oldMessage = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:foobar
SEQUENCE:2
ORGANIZER;CN=Strunk:mailto:strunk@example.org
ATTENDEE;CN=One:mailto:one@example.org
DTSTART:20140716T120000Z
DTEND:20140716T130000Z
STATUS:CONFIRMED
END:VEVENT
END:VCALENDAR
ICS;

$newMessage = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:foobar
SEQUENCE:3
ORGANIZER;CN=Strunk:mailto:strunk@example.org
ATTENDEE;CN=One:mailto:one@example.org
DTSTART:20140716T120000Z
DTEND:20140716T130000Z
STATUS:CANCELLED
END:VEVENT
END:VCALENDAR
ICS;

$version = Version::VERSION;

$expected = [
[
'uid' => 'foobar',
'method' => 'CANCEL',
'component' => 'VEVENT',
'message' => <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Sabre//Sabre VObject $version//EN
CALSCALE:GREGORIAN
METHOD:CANCEL
BEGIN:VEVENT
UID:foobar
DTSTAMP:**ANY**
SEQUENCE:3
DTSTART:20140716T120000Z
DTEND:20140716T130000Z
ORGANIZER;CN=Strunk:mailto:strunk@example.org
ATTENDEE;CN=One:mailto:one@example.org
END:VEVENT
END:VCALENDAR
ICS,
],
];

$this->parse($oldMessage, $newMessage, $expected, 'mailto:strunk@example.org');
}
}

0 comments on commit 28e191b

Please sign in to comment.