mirror of
https://github.com/nextcloud/server.git
synced 2026-04-29 10:03:32 -04:00
feat: Add X-NC-Disable-Scheduling property to allow skipping scheduling
Signed-off-by: SebastianKrupinski <krupinskis05@gmail.com>
This commit is contained in:
parent
8fdae44816
commit
bfa23ff6c7
2 changed files with 29 additions and 2 deletions
|
|
@ -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';
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue