From 643faff7d5bd06bfa162bb6fb86130675986fe8b Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Thu, 7 Nov 2024 15:13:13 -0500 Subject: [PATCH] feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling Signed-off-by: SebastianKrupinski --- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 12 ++++++++++-- .../unit/CalDAV/Schedule/IMipPluginTest.php | 19 +++++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index dcac8db2bbd..4d771f0f7f8 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -132,8 +132,16 @@ class IMipPlugin extends SabreIMipPlugin { * @return void */ public function schedule(Message $iTipMessage) { - // Not sending any emails if the system considers the update - // insignificant. + + // do not send imip messages if external system already did + /** @psalm-suppress UndefinedPropertyFetch */ + if ($iTipMessage->message?->VEVENT?->{'X-NC-DISABLE-SCHEDULING'}?->getValue() === 'true') { + if (!$iTipMessage->scheduleStatus) { + $iTipMessage->scheduleStatus = '1.0;We got the message, but iMip messages are disabled for this event'; + } + return; + } + // Not sending any emails if the system considers the update insignificant if (!$iTipMessage->significantChange) { if (!$iTipMessage->scheduleStatus) { $iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email'; diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index de6218bf5f5..7813a7942fe 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -783,4 +783,23 @@ class IMipPluginTest extends TestCase { $this->plugin->schedule($message); $this->assertEquals('1.1', $message->getScheduleStatus()); } + + public function testImipDisabledForEvent(): void { + // construct iTip message with event and attendees + $calendar = new VCalendar(); + $calendar->add('VEVENT', ['UID' => 'uid-1234']); + $event = $calendar->VEVENT; + $event->add('ORGANIZER', 'mailto:gandalf@wiz.ard'); + $event->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']); + $event->add('X-NC-DISABLE-SCHEDULING', 'true'); + $message = new Message(); + $message->method = 'REQUEST'; + $message->message = $calendar; + $message->sender = 'mailto:gandalf@wiz.ard'; + $message->senderName = 'Mr. Wizard'; + $message->recipient = 'mailto:' . 'frodo@hobb.it'; + + $this->plugin->schedule($message); + $this->assertEquals('1.0;We got the message, but iMip messages are disabled for this event', $message->scheduleStatus); + } } -- 2.39.5