]> source.dussan.org Git - nextcloud-server.git/commitdiff
feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling backport/49139/stable30 49234/head
authorSebastianKrupinski <krupinskis05@gmail.com>
Thu, 7 Nov 2024 20:13:13 +0000 (15:13 -0500)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 12 Nov 2024 15:43:20 +0000 (15:43 +0000)
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php

index 1958531630ade8f71b56b04e5c54720e93013f93..1cfe8f47cb5b7eb1387ae893cb1efa3922d4b97e 100644 (file)
@@ -109,8 +109,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';
index bda3182d117bb95c8974eeed8966d19ae07e54cd..c8dfe257bf2bbfd8ba544f8c5e75e3633986651d 100644 (file)
@@ -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);
+       }
 }