Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OCA\DAV\CalDAV\Auth\PublicPrincipalPlugin;
use OCA\DAV\CalDAV\DefaultCalendarValidator;
use OCA\DAV\CalDAV\Publishing\PublishPlugin;
use OCA\DAV\CalDAV\Schedule\IMipPlugin;
use OCA\DAV\Connector\Sabre\AnonymousOptionsPlugin;
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCA\DAV\Connector\Sabre\CachingTree;
Expand Down Expand Up @@ -113,6 +114,11 @@ public function __construct(bool $public = true) {
* @return void
*/
public function handleITipMessage(Message $iTipMessage) {
// Register the iMIP plugin only for the invitation-link flow, it must stay absent for createFromStringMinimal() and CalendarImpl
if ($this->server->getPlugin('imip') === null) {
$this->server->addPlugin(Server::get(IMipPlugin::class));
}

/** @var \OCA\DAV\CalDAV\Schedule\Plugin $schedulingPlugin */
$schedulingPlugin = $this->server->getPlugin('caldav-schedule');
$schedulingPlugin->scheduleLocalDelivery($iTipMessage);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\DAV\Tests\unit\CalDAV\InvitationResponse;

use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
use OCA\DAV\CalDAV\Schedule\IMipPlugin;
use PHPUnit\Framework\Attributes\Group;
use Sabre\VObject\ITip\Message;
use Sabre\VObject\Reader;
use Test\TestCase;

#[Group(name: 'DB')]
class InvitationResponseServerTest extends TestCase {
public function testIMipPluginIsOnlyRegisteredWhenHandlingITipMessages(): void {
$server = new InvitationResponseServer();

// Not registered by the constructor: other flows (e.g. createFromStringMinimal) must not send emails
$this->assertNull($server->getServer()->getPlugin('imip'));

$message = new Message();
$message->uid = 'fb1bc04c-ac3e-4f5d-8329-7a1e0b07a1e0';
$message->component = 'VEVENT';
$message->method = 'REPLY';
$message->sequence = 0;
$message->sender = 'mailto:attendee@example.com';
$message->recipient = 'mailto:unknown-organizer@example.com';
$message->message = Reader::read(<<<EOF
BEGIN:VCALENDAR
VERSION:2.0
METHOD:REPLY
BEGIN:VEVENT
ATTENDEE;PARTSTAT=ACCEPTED:mailto:attendee@example.com
ORGANIZER:mailto:unknown-organizer@example.com
UID:fb1bc04c-ac3e-4f5d-8329-7a1e0b07a1e0
SEQUENCE:0
DTSTAMP:20260611T120000Z
END:VEVENT
END:VCALENDAR
EOF);

$server->handleITipMessage($message);

$this->assertInstanceOf(IMipPlugin::class, $server->getServer()->getPlugin('imip'));
}
}