aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorDaniel <mail@danielkesselberg.de>2024-12-10 19:14:00 +0100
committerGitHub <noreply@github.com>2024-12-10 19:14:00 +0100
commit85f4f4f480516b9d734273f999780949ac2dc957 (patch)
tree883373cb8292c9adb0d6b143ee8dfbffb939bfe7 /apps
parent28ec9c7e80e825aea2537f865e2862aecf25c8f1 (diff)
parent04cb122af2f78dd223e413326994aba5c3b57114 (diff)
downloadnextcloud-server-85f4f4f480516b9d734273f999780949ac2dc957.tar.gz
nextcloud-server-85f4f4f480516b9d734273f999780949ac2dc957.zip
Merge pull request #49503 from nextcloud/fix/issue-48528-disable-itip-and-imip-messages-2
fix(CalDAV): disable both iTip and iMip messages
Diffstat (limited to 'apps')
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php8
-rw-r--r--apps/dav/lib/CalDAV/Schedule/Plugin.php8
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php19
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php39
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 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..eeeebe16b88 100644
--- a/apps/dav/lib/CalDAV/Schedule/Plugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/Plugin.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -162,10 +163,15 @@ class Plugin extends \Sabre\CalDAV\Schedule\Plugin {
try {
+ // Do not generate iTip and iMip messages if scheduling is disabled for this message
+ if ($request->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 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..8d20fd5f9df 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -738,4 +739,42 @@ 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
+ $request = new Request(
+ 'PUT',
+ '/remote.php/dav/calendars/user1/personal/B0DC78AE-6DD7-47E3-80BE-89F23E6D5383.ics',
+ ['x-nc-scheduling' => '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
+ );
+ }
}