Skip to content

Commit c6216ec

Browse files
Merge pull request nextcloud#49233 from nextcloud/backport/49139/stable29
[stable29] feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling
2 parents 8200522 + 643faff commit c6216ec

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

apps/dav/lib/CalDAV/Schedule/IMipPlugin.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,16 @@ public function beforeWriteContent($uri, INode $node, $data, $modified): void {
132132
* @return void
133133
*/
134134
public function schedule(Message $iTipMessage) {
135-
// Not sending any emails if the system considers the update
136-
// insignificant.
135+
136+
// do not send imip messages if external system already did
137+
/** @psalm-suppress UndefinedPropertyFetch */
138+
if ($iTipMessage->message?->VEVENT?->{'X-NC-DISABLE-SCHEDULING'}?->getValue() === 'true') {
139+
if (!$iTipMessage->scheduleStatus) {
140+
$iTipMessage->scheduleStatus = '1.0;We got the message, but iMip messages are disabled for this event';
141+
}
142+
return;
143+
}
144+
// Not sending any emails if the system considers the update insignificant
137145
if (!$iTipMessage->significantChange) {
138146
if (!$iTipMessage->scheduleStatus) {
139147
$iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email';

apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,4 +783,23 @@ public function testNoButtons(): void {
783783
$this->plugin->schedule($message);
784784
$this->assertEquals('1.1', $message->getScheduleStatus());
785785
}
786+
787+
public function testImipDisabledForEvent(): void {
788+
// construct iTip message with event and attendees
789+
$calendar = new VCalendar();
790+
$calendar->add('VEVENT', ['UID' => 'uid-1234']);
791+
$event = $calendar->VEVENT;
792+
$event->add('ORGANIZER', 'mailto:gandalf@wiz.ard');
793+
$event->add('ATTENDEE', 'mailto:' . 'frodo@hobb.it', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
794+
$event->add('X-NC-DISABLE-SCHEDULING', 'true');
795+
$message = new Message();
796+
$message->method = 'REQUEST';
797+
$message->message = $calendar;
798+
$message->sender = 'mailto:gandalf@wiz.ard';
799+
$message->senderName = 'Mr. Wizard';
800+
$message->recipient = 'mailto:' . 'frodo@hobb.it';
801+
802+
$this->plugin->schedule($message);
803+
$this->assertEquals('1.0;We got the message, but iMip messages are disabled for this event', $message->scheduleStatus);
804+
}
786805
}

0 commit comments

Comments
 (0)