diff options
author | Sebastian Krupinski <165827823+SebastianKrupinski@users.noreply.github.com> | 2024-11-12 10:40:07 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 10:40:07 -0500 |
commit | de1c175d39f2513f3a99e393c9ea70175e43ae10 (patch) | |
tree | 451b3b3e9bae4264ae974773ad439ccc08ef6985 /apps/dav | |
parent | 17659d327ac2d6d62405ca489fb0f1432c4e03e4 (diff) | |
parent | f8d50eb9b511140bcc348888d625142375910031 (diff) | |
download | nextcloud-server-de1c175d39f2513f3a99e393c9ea70175e43ae10.tar.gz nextcloud-server-de1c175d39f2513f3a99e393c9ea70175e43ae10.zip |
Merge pull request #49139 from nextcloud/enh/issue-48528-disable-imip-messages
feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling
Diffstat (limited to 'apps/dav')
-rw-r--r-- | apps/dav/lib/CalDAV/Schedule/IMipPlugin.php | 12 | ||||
-rw-r--r-- | apps/dav/tests/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 f88625b551b..084d7201933 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -95,8 +95,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 36ce091fc69..18208981038 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -890,4 +890,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); + } } |