Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117813992
D5496.1775281602.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None
D5496.1775281602.diff
View Options
diff --git a/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php b/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php
--- a/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php
+++ b/src/app/Policy/Mailfilter/Modules/ItipModule/RequestHandler.php
@@ -130,10 +130,20 @@
*/
protected function mergeComponents(Component $to, Component $from): void
{
- // TODO: Every property? What other properties? EXDATE/RDATE? ATTENDEE?
+ // TODO: Every property? What other properties? EXDATE/RDATE? ORGANIZER? ATTACH?
+ // TODO: Removal of RRULE from the master event
$props = ['SEQUENCE', 'RRULE'];
foreach ($props as $prop) {
- $to->{$prop} = $from->{$prop} ?? null;
+ if (isset($from->{$prop})) {
+ $to->{$prop} = $from->{$prop};
+ }
+ }
+
+ // Replace the list of ATTENDEEs
+ $to->remove('ATTENDEE');
+ foreach ($from->ATTENDEE ?? [] as $attendee) {
+ $class = $attendee::class;
+ $to->add(new $class($to->parent, 'ATTENDEE', $attendee->getValue(), $attendee->parameters()));
}
// If RRULE contains UNTIL remove exceptions from the timestamp forward
diff --git a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
--- a/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
+++ b/src/tests/Feature/Policy/Mailfilter/Modules/ItipModule/RequestHandlerTest.php
@@ -49,7 +49,27 @@
Notification::assertNothingSent();
- // TODO: Test REQUEST to an existing event, and other corner cases
+ // Test REQUEST to an existing event, and other corner cases
+ $replaces = [
+ 'CN=Ned;PARTSTAT=NEEDS-ACTION' => 'CN=Ned;PARTSTAT=ACCEPTED',
+ ];
+ $parser = MailParserTest::getParserForFile('mailfilter/itip1_request.eml', 'john@kolab.org', 'jack@kolab.org', $replaces);
+ $module = new ItipModule();
+ $result = $module->handle($parser);
+
+ $this->assertNull($result);
+
+ $list = $this->davList($account, 'Calendar', 'event');
+ $this->assertCount(1, $list);
+ $this->assertSame('5463F1DDF6DA264A3FC70E7924B729A5-D9F1889254B163F5', $list[0]->uid);
+ $this->assertCount(2, $list[0]->attendees);
+ $this->assertSame('john@kolab.org', $list[0]->attendees[0]['email']);
+ $this->assertSame('NEEDS-ACTION', $list[0]->attendees[0]['partstat']);
+ $this->assertSame('ned@kolab.org', $list[0]->attendees[1]['email']);
+ $this->assertSame('ACCEPTED', $list[0]->attendees[1]['partstat']);
+ $this->assertSame('jack@kolab.org', $list[0]->organizer['email']);
+
+ Notification::assertNothingSent();
// TODO: Test various supported message structures (ItipModule::getItip())
}
@@ -93,7 +113,31 @@
$this->assertSame('ned@kolab.org', $attendees[1]['email']);
$this->assertSame('NEEDS-ACTION', $attendees[1]['partstat']);
- // TODO: Test updating an existing occurence
+ // Test updating an existing occurence
+ $replaces = [
+ 'CN=Ned;PARTSTAT=NEEDS-ACTION' => 'CN=Ned;PARTSTAT=ACCEPTED',
+ ];
+ $parser = MailParserTest::getParserForFile('mailfilter/itip2_request.eml', 'john@kolab.org', 'jack@kolab.org', $replaces);
+ $module = new ItipModule();
+ $result = $module->handle($parser);
+
+ $this->assertNull($result);
+
+ $list = $this->davList($account, 'Calendar', 'event');
+ $this->assertCount(1, $list);
+ $this->assertSame('5463F1DDF6DA264A3FC70E7924B729A5-222222', $list[0]->uid);
+ $this->assertCount(2, $attendees = $list[0]->attendees);
+ $this->assertSame('john@kolab.org', $attendees[0]['email']);
+ $this->assertSame('ACCEPTED', $attendees[0]['partstat']);
+ $this->assertSame('ned@kolab.org', $attendees[1]['email']);
+ $this->assertSame('TENTATIVE', $attendees[1]['partstat']);
+ $this->assertSame('jack@kolab.org', $list[0]->organizer['email']);
+ $this->assertCount(1, $list[0]->exceptions);
+ $this->assertCount(2, $attendees = $list[0]->exceptions[0]->attendees);
+ $this->assertSame('john@kolab.org', $attendees[0]['email']);
+ $this->assertSame('NEEDS-ACTION', $attendees[0]['partstat']);
+ $this->assertSame('ned@kolab.org', $attendees[1]['email']);
+ $this->assertSame('ACCEPTED', $attendees[1]['partstat']);
// Jack sends REQUEST with RRULE containing UNTIL parameter, which is a case when
// an organizer deletes "this and future" event occurence
@@ -109,11 +153,12 @@
$list = array_filter($list, static fn ($event) => $event->uid == '5464F1DDF6DA264A3FC70E7924B729A5-333333');
$event = $list[array_key_first($list)];
+ $this->assertCount(1, $list);
$this->assertCount(2, $attendees = $event->attendees);
$this->assertSame('john@kolab.org', $attendees[0]['email']);
$this->assertSame('ACCEPTED', $attendees[0]['partstat']);
$this->assertSame('ned@kolab.org', $attendees[1]['email']);
- $this->assertSame('TENTATIVE', $attendees[1]['partstat']);
+ $this->assertSame('NEEDS-ACTION', $attendees[1]['partstat']);
$this->assertCount(1, $event->exceptions);
$this->assertSame('20240717T123000', $event->exceptions[0]->recurrenceId);
diff --git a/src/tests/Unit/Policy/Mailfilter/MailParserTest.php b/src/tests/Unit/Policy/Mailfilter/MailParserTest.php
--- a/src/tests/Unit/Policy/Mailfilter/MailParserTest.php
+++ b/src/tests/Unit/Policy/Mailfilter/MailParserTest.php
@@ -143,9 +143,14 @@
/**
* Create mail parser instance for specified test message
*/
- public static function getParserForFile(string $file, $recipient = null, $sender = null): MailParser
+ public static function getParserForFile(string $file, $recipient = null, $sender = null, $replaces = []): MailParser
{
$mail = file_get_contents(__DIR__ . '/../../../data/' . $file);
+
+ foreach ($replaces as $from => $to) {
+ $mail = str_replace($from, $to, $mail);
+ }
+
$mail = str_replace("\n", "\r\n", $mail);
$stream = fopen('php://memory', 'r+');
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Apr 4, 5:46 AM (8 h, 5 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18828281
Default Alt Text
D5496.1775281602.diff (6 KB)
Attached To
Mode
D5496: Itip: Fix handling REQUEST to an existing event
Attached
Detach File
Event Timeline