Skip to content

Commit de1c175

Browse files
Merge pull request #49139 from nextcloud/enh/issue-48528-disable-imip-messages
feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling
2 parents 17659d3 + f8d50eb commit de1c175

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
@@ -95,8 +95,16 @@ public function beforeWriteContent($uri, INode $node, $data, $modified): void {
9595
* @return void
9696
*/
9797
public function schedule(Message $iTipMessage) {
98-
// Not sending any emails if the system considers the update
99-
// insignificant.
98+
99+
// do not send imip messages if external system already did
100+
/** @psalm-suppress UndefinedPropertyFetch */
101+
if ($iTipMessage->message?->VEVENT?->{'X-NC-DISABLE-SCHEDULING'}?->getValue() === 'true') {
102+
if (!$iTipMessage->scheduleStatus) {
103+
$iTipMessage->scheduleStatus = '1.0;We got the message, but iMip messages are disabled for this event';
104+
}
105+
return;
106+
}
107+
// Not sending any emails if the system considers the update insignificant
100108
if (!$iTipMessage->significantChange) {
101109
if (!$iTipMessage->scheduleStatus) {
102110
$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
@@ -890,4 +890,23 @@ public function testNoButtons(): void {
890890
$this->plugin->schedule($message);
891891
$this->assertEquals('1.1', $message->getScheduleStatus());
892892
}
893+
894+
public function testImipDisabledForEvent(): void {
895+
// construct iTip message with event and attendees
896+
$calendar = new VCalendar();
897+
$calendar->add('VEVENT', ['UID' => 'uid-1234']);
898+
$event = $calendar->VEVENT;
899+
$event->add('ORGANIZER', 'mailto:[email protected]');
900+
$event->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
901+
$event->add('X-NC-DISABLE-SCHEDULING', 'true');
902+
$message = new Message();
903+
$message->method = 'REQUEST';
904+
$message->message = $calendar;
905+
$message->sender = 'mailto:[email protected]';
906+
$message->senderName = 'Mr. Wizard';
907+
$message->recipient = 'mailto:' . '[email protected]';
908+
909+
$this->plugin->schedule($message);
910+
$this->assertEquals('1.0;We got the message, but iMip messages are disabled for this event', $message->scheduleStatus);
911+
}
893912
}

0 commit comments

Comments
 (0)