Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable21] Scheduling plugin not updating responding attendee status #29386

Merged
merged 2 commits into from
Oct 22, 2021
Merged
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 @@ -122,4 +122,10 @@ public function handleITipMessage(Message $iTipMessage) {
$schedulingPlugin = $this->server->getPlugin('caldav-schedule');
$schedulingPlugin->scheduleLocalDelivery($iTipMessage);
}

public function isExternalAttendee(string $principalUri): bool {
/** @var \Sabre\DAVACL\Plugin $aclPlugin */
$aclPlugin = $this->server->getPlugin('acl');
return $aclPlugin->getPrincipalByUri($principalUri) === null;
}
}
7 changes: 6 additions & 1 deletion apps/dav/lib/Controller/InvitationResponseController.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ private function buildITipResponse(array $row, string $partStat, int $guests = n
$iTipMessage->method = 'REPLY';
$iTipMessage->sequence = $row['sequence'];
$iTipMessage->sender = $row['attendee'];
$iTipMessage->recipient = $row['organizer'];

if ($this->responseServer->isExternalAttendee($row['attendee'])) {
$iTipMessage->recipient = $row['organizer'];
} else {
$iTipMessage->recipient = $row['attendee'];
}

$message = <<<EOF
BEGIN:VCALENDAR
Expand Down
96 changes: 72 additions & 24 deletions apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,17 @@ protected function setUp(): void {
);
}

public function testAccept() {
public function attendeeProvider(): array {
return [
'local attendee' => [false],
'external attendee' => [true]
];
}

/**
* @dataProvider attendeeProvider
*/
public function testAccept(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
'uid' => 'this-is-the-events-uid',
Expand Down Expand Up @@ -109,21 +119,26 @@ public function testAccept() {
$called = false;
$this->responseServer->expects($this->once())
->method('handleITipMessage')
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
->willReturnCallback(function (Message $iTipMessage) use (&$called, $isExternalAttendee, $expected) {
$called = true;
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
$this->assertEquals('VEVENT', $iTipMessage->component);
$this->assertEquals('REPLY', $iTipMessage->method);
$this->assertEquals(null, $iTipMessage->sequence);
$this->assertEquals('mailto:[email protected]', $iTipMessage->sender);
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
if ($isExternalAttendee) {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
} else {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
}

$iTipMessage->scheduleStatus = '1.2;Message delivered locally';

$this->assertEquals($expected, $iTipMessage->message->serialize());
});


$this->responseServer->expects($this->once())
->method('isExternalAttendee')
->willReturn($isExternalAttendee);

$response = $this->controller->accept('TOKEN123');
$this->assertInstanceOf(TemplateResponse::class, $response);
Expand All @@ -132,7 +147,10 @@ public function testAccept() {
$this->assertTrue($called);
}

public function testAcceptSequence() {
/**
* @dataProvider attendeeProvider
*/
public function testAcceptSequence(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
'uid' => 'this-is-the-events-uid',
Expand Down Expand Up @@ -165,21 +183,26 @@ public function testAcceptSequence() {
$called = false;
$this->responseServer->expects($this->once())
->method('handleITipMessage')
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
->willReturnCallback(function (Message $iTipMessage) use (&$called, $isExternalAttendee, $expected) {
$called = true;
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
$this->assertEquals('VEVENT', $iTipMessage->component);
$this->assertEquals('REPLY', $iTipMessage->method);
$this->assertEquals(1337, $iTipMessage->sequence);
$this->assertEquals('mailto:[email protected]', $iTipMessage->sender);
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
if ($isExternalAttendee) {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
} else {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
}

$iTipMessage->scheduleStatus = '1.2;Message delivered locally';

$this->assertEquals($expected, $iTipMessage->message->serialize());
});


$this->responseServer->expects($this->once())
->method('isExternalAttendee')
->willReturn($isExternalAttendee);

$response = $this->controller->accept('TOKEN123');
$this->assertInstanceOf(TemplateResponse::class, $response);
Expand All @@ -188,7 +211,10 @@ public function testAcceptSequence() {
$this->assertTrue($called);
}

public function testAcceptRecurrenceId() {
/**
* @dataProvider attendeeProvider
*/
public function testAcceptRecurrenceId(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
'uid' => 'this-is-the-events-uid',
Expand Down Expand Up @@ -222,21 +248,26 @@ public function testAcceptRecurrenceId() {
$called = false;
$this->responseServer->expects($this->once())
->method('handleITipMessage')
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
->willReturnCallback(function (Message $iTipMessage) use (&$called, $isExternalAttendee, $expected) {
$called = true;
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
$this->assertEquals('VEVENT', $iTipMessage->component);
$this->assertEquals('REPLY', $iTipMessage->method);
$this->assertEquals(0, $iTipMessage->sequence);
$this->assertEquals('mailto:[email protected]', $iTipMessage->sender);
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
if ($isExternalAttendee) {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
} else {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
}

$iTipMessage->scheduleStatus = '1.2;Message delivered locally';

$this->assertEquals($expected, $iTipMessage->message->serialize());
});


$this->responseServer->expects($this->once())
->method('isExternalAttendee')
->willReturn($isExternalAttendee);

$response = $this->controller->accept('TOKEN123');
$this->assertInstanceOf(TemplateResponse::class, $response);
Expand Down Expand Up @@ -272,7 +303,10 @@ public function testAcceptExpiredToken() {
$this->assertEquals([], $response->getParams());
}

public function testDecline() {
/**
* @dataProvider attendeeProvider
*/
public function testDecline(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
'uid' => 'this-is-the-events-uid',
Expand Down Expand Up @@ -305,21 +339,26 @@ public function testDecline() {
$called = false;
$this->responseServer->expects($this->once())
->method('handleITipMessage')
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
->willReturnCallback(function (Message $iTipMessage) use (&$called, $isExternalAttendee, $expected) {
$called = true;
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
$this->assertEquals('VEVENT', $iTipMessage->component);
$this->assertEquals('REPLY', $iTipMessage->method);
$this->assertEquals(null, $iTipMessage->sequence);
$this->assertEquals('mailto:[email protected]', $iTipMessage->sender);
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
if ($isExternalAttendee) {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
} else {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
}

$iTipMessage->scheduleStatus = '1.2;Message delivered locally';

$this->assertEquals($expected, $iTipMessage->message->serialize());
});


$this->responseServer->expects($this->once())
->method('isExternalAttendee')
->willReturn($isExternalAttendee);

$response = $this->controller->decline('TOKEN123');
$this->assertInstanceOf(TemplateResponse::class, $response);
Expand All @@ -335,7 +374,10 @@ public function testOptions() {
$this->assertEquals(['token' => 'TOKEN123'], $response->getParams());
}

public function testProcessMoreOptionsResult() {
/**
* @dataProvider attendeeProvider
*/
public function testProcessMoreOptionsResult(bool $isExternalAttendee): void {
$this->request->expects($this->at(0))
->method('getParam')
->with('partStat')
Expand Down Expand Up @@ -383,20 +425,26 @@ public function testProcessMoreOptionsResult() {
$called = false;
$this->responseServer->expects($this->once())
->method('handleITipMessage')
->willReturnCallback(function (Message $iTipMessage) use (&$called, $expected) {
->willReturnCallback(function (Message $iTipMessage) use (&$called, $isExternalAttendee, $expected) {
$called = true;
$this->assertEquals('this-is-the-events-uid', $iTipMessage->uid);
$this->assertEquals('VEVENT', $iTipMessage->component);
$this->assertEquals('REPLY', $iTipMessage->method);
$this->assertEquals(null, $iTipMessage->sequence);
$this->assertEquals('mailto:[email protected]', $iTipMessage->sender);
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
if ($isExternalAttendee) {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
} else {
$this->assertEquals('mailto:[email protected]', $iTipMessage->recipient);
}

$iTipMessage->scheduleStatus = '1.2;Message delivered locally';

$this->assertEquals($expected, $iTipMessage->message->serialize());
});

$this->responseServer->expects($this->once())
->method('isExternalAttendee')
->willReturn($isExternalAttendee);


$response = $this->controller->processMoreOptionsResult('TOKEN123');
Expand Down