Skip to content

Commit

Permalink
Merge pull request #49253 from nextcloud/backport/49139/stable28
Browse files Browse the repository at this point in the history
[stable28] feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling
  • Loading branch information
SebastianKrupinski authored Nov 13, 2024
2 parents fffa63e + c1cbdb4 commit 1a411ff
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
12 changes: 10 additions & 2 deletions apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,16 @@ public function beforeWriteContent($uri, INode $node, $data, $modified): void {
* @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';
Expand Down
19 changes: 19 additions & 0 deletions apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -783,4 +783,23 @@ public function testNoButtons(): void {
$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:[email protected]');
$event->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'Frodo']);
$event->add('X-NC-DISABLE-SCHEDULING', 'true');
$message = new Message();
$message->method = 'REQUEST';
$message->message = $calendar;
$message->sender = 'mailto:[email protected]';
$message->senderName = 'Mr. Wizard';
$message->recipient = 'mailto:' . '[email protected]';

$this->plugin->schedule($message);
$this->assertEquals('1.0;We got the message, but iMip messages are disabled for this event', $message->scheduleStatus);
}
}

0 comments on commit 1a411ff

Please sign in to comment.