From 04cb122af2f78dd223e413326994aba5c3b57114 Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Tue, 26 Nov 2024 19:52:01 -0500 Subject: [PATCH] fix: disable both iTip and iMip messages Signed-off-by: SebastianKrupinski --- apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 8 ---- apps/dav/lib/CalDAV/Schedule/Plugin.php | 8 +++- .../unit/CalDAV/Schedule/IMipPluginTest.php | 19 --------- .../tests/unit/CalDAV/Schedule/PluginTest.php | 39 +++++++++++++++++++ 4 files changed, 46 insertions(+), 28 deletions(-) diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index d81d85573fc01..0aecb18ce8092 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -97,14 +97,6 @@ public function beforeWriteContent($uri, INode $node, $data, $modified): void { */ 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 eebfe2ead493d..eeeebe16b8851 100644 --- a/apps/dav/lib/CalDAV/Schedule/Plugin.php +++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php @@ -1,4 +1,5 @@ getHeader('x-nc-scheduling') === 'false') { + return; + } + if (!$this->scheduleReply($this->server->httpRequest)) { 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 94c39e42d16af..0137f52835583 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -997,23 +997,4 @@ public function testNoButtons(): void { $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 06261ca6fa5ae..8d20fd5f9df47 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php @@ -1,4 +1,5 @@ 'false'] + ); + $request->setBaseUrl('/remote.php/dav/'); + // construct server response + $response = new Response(); + // construct server tree + $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 empty calendar event + $vCalendar = new VCalendar(); + $vEvent = $vCalendar->add('VEVENT', []); + // define flags + $newFlag = true; + $modifiedFlag = false; + // execute method + $this->plugin->calendarObjectChange( + $request, + $response, + $vCalendar, + 'calendars/user1/personal', + $modifiedFlag, + $newFlag + ); + } }