Skip to content

Commit

Permalink
fix: check if event status was changed to cancelled and generate appr…
Browse files Browse the repository at this point in the history
…opriate message

Signed-off-by: SebastianKrupinski <[email protected]>
  • Loading branch information
SebastianKrupinski committed Sep 5, 2024
1 parent fad6391 commit d7883c3
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:[email protected]');
}

public function testInviteStatusCancelled(): void
{
$oldMessage = <<<ICS
BEGIN:VCALENDAR
VERSION:2.0
BEGIN:VEVENT
UID:foobar
SEQUENCE:2
ORGANIZER;CN=Strunk:mailto:[email protected]
ATTENDEE;CN=One:mailto:[email protected]
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:[email protected]
ATTENDEE;CN=One:mailto:[email protected]
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:[email protected]
ATTENDEE;CN=One:mailto:[email protected]
END:VEVENT
END:VCALENDAR
ICS,
],
];

$this->parse($oldMessage, $newMessage, $expected, 'mailto:[email protected]');
}
}

0 comments on commit d7883c3

Please sign in to comment.