diff options
author | SebastianKrupinski <krupinskis05@gmail.com> | 2024-11-26 19:43:58 -0500 |
---|---|---|
committer | SebastianKrupinski <krupinskis05@gmail.com> | 2024-11-26 19:43:58 -0500 |
commit | 4a421b98c75bafee58a70209cb3a8f6b9466674f (patch) | |
tree | b95a215f76d8369697a7ac9e12218b1417f8c423 | |
parent | d17895e0b7a4d9d31c5236139061a6cf064bf371 (diff) | |
download | nextcloud-server-fix/issue-48528-disable-itip-and-imip-messages.tar.gz nextcloud-server-fix/issue-48528-disable-itip-and-imip-messages.zip |
fix: disable both iTip and iMip messagesfix/issue-48528-disable-itip-and-imip-messages
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 8 | ||||
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/Plugin.php | 8 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php | 19 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php | 58 |
4 files changed, 65 insertions, 28 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index d81d85573fc..0aecb18ce80 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -97,14 +97,6 @@ class IMipPlugin extends SabreIMipPlugin { */ public function schedule(Message $iTipMessage) { - // 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) { diff --git a/apps/dav/lib/CalDAV/Schedule/Plugin.php b/apps/dav/lib/CalDAV/Schedule/Plugin.php index eebfe2ead49..9ce5a91442f 100644 --- a/apps/dav/lib/CalDAV/Schedule/Plugin.php +++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php @@ -165,7 +165,13 @@ class Plugin extends \Sabre\CalDAV\Schedule\Plugin { if (!$this->scheduleReply($this->server->httpRequest)) { return; } - + + // Do not generate iTip and iMip messages if scheduling is disabled for this message + /** @psalm-suppress UndefinedPropertyFetch */ + if ($vCal->VEVENT?->{'X-NC-DISABLE-SCHEDULING'}?->getValue() === 'true') { + return; + } + /** @var Calendar $calendarNode */ $calendarNode = $this->server->tree->getNodeForPath($calendarPath); // extract addresses for owner diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index 94c39e42d16..0137f528355 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -997,23 +997,4 @@ 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); - } } diff --git a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php index 06261ca6fa5..8089a576154 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php @@ -738,4 +738,62 @@ class PluginTest extends TestCase { } + /** + * Test Calendar Event Creation with iTip and iMip disabled + * + * Should generate 2 messages for attendees User 2 and User External + */ + public function testCalendarObjectChangeWithSchedulingDisabled(): void { + + // construct server request object + $request = new Request( + 'PUT', + '/remote.php/dav/calendars/user1/personal/B0DC78AE-6DD7-47E3-80BE-89F23E6D5383.ics' + ); + $request->setBaseUrl('/remote.php/dav/'); + // construct server response object + $response = new Response(); + // construct server tree object + $tree = $this->createMock(Tree::class); + $tree->expects($this->never()) + ->method('getNodeForPath'); + // construct server properties and returns + $this->server->httpRequest = $request; + $this->server->tree = $tree; + // construct calendar with a 1 hour event and same start/end time zones + $vCalendar = new VCalendar(); + $vEvent = $vCalendar->add('VEVENT', []); + $vEvent->UID->setValue('96a0e6b1-d886-4a55-a60d-152b31401dcc'); + $vEvent->add('DTSTART', '20240701T080000', ['TZID' => 'America/Toronto']); + $vEvent->add('DTEND', '20240701T090000', ['TZID' => 'America/Toronto']); + $vEvent->add('SUMMARY', 'Test Recurring Event'); + $vEvent->add('ORGANIZER', 'mailto:user1@testing.local', ['CN' => 'User One']); + $vEvent->add('ATTENDEE', 'mailto:user2@testing.local', [ + 'CN' => 'User Two', + 'CUTYPE' => 'INDIVIDUAL', + 'PARTSTAT' => 'NEEDS-ACTION', + 'ROLE' => 'REQ-PARTICIPANT', + 'RSVP' => 'TRUE' + ]); + $vEvent->add('ATTENDEE', 'mailto:user@external.local', [ + 'CN' => 'User External', + 'CUTYPE' => 'INDIVIDUAL', + 'PARTSTAT' => 'NEEDS-ACTION', + 'ROLE' => 'REQ-PARTICIPANT', + 'RSVP' => 'TRUE' + ]); + $vEvent->add('X-NC-DISABLE-SCHEDULING', 'true'); + // define flags + $newFlag = true; + $modifiedFlag = false; + // execute method + $this->plugin->calendarObjectChange( + $request, + $response, + $vCalendar, + 'calendars/user1/personal', + $modifiedFlag, + $newFlag + ); + } } |