From 854cfe7245b6b7474353f72bcd81ae8a42f198a4 Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Sat, 7 Sep 2024 20:18:50 -0400 Subject: [PATCH 1/4] feat: add iMip Request Handling Signed-off-by: SebastianKrupinski --- lib/Service/IMipService.php | 6 +++++- tests/Unit/Service/IMipServiceTest.php | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/Service/IMipService.php b/lib/Service/IMipService.php index b23f2de22d..a8c48dfc63 100644 --- a/lib/Service/IMipService.php +++ b/lib/Service/IMipService.php @@ -135,7 +135,11 @@ public function process(): void { $sender = $imapMessage->getFrom()->first()->getEmail(); $recipient = $account->getEmail(); foreach ($imapMessage->scheduling as $schedulingInfo) { // an IMAP message could contain more than one iMIP object - if ($schedulingInfo['method'] === 'REPLY') { + if ($schedulingInfo['method'] === 'REQUEST') { + $processed = $this->calendarManager->handleIMipRequest($principalUri, $sender, $recipient, $schedulingInfo['contents']); + $message->setImipProcessed($processed); + $message->setImipError(!$processed); + } elseif ($schedulingInfo['method'] === 'REPLY') { $processed = $this->calendarManager->handleIMipReply($principalUri, $sender, $recipient, $schedulingInfo['contents']); $message->setImipProcessed($processed); $message->setImipError(!$processed); diff --git a/tests/Unit/Service/IMipServiceTest.php b/tests/Unit/Service/IMipServiceTest.php index 6b1bd6e2e2..ecdfc8e03e 100644 --- a/tests/Unit/Service/IMipServiceTest.php +++ b/tests/Unit/Service/IMipServiceTest.php @@ -285,12 +285,14 @@ public function testIsRequest(): void { ->willReturn('pam@stardew-bus-company.com'); $this->logger->expects(self::never()) ->method('info'); - $this->calendarManager->expects(self::never()) - ->method('handleIMipReply'); - $this->calendarManager->expects(self::never()) - ->method('handleIMipCancel'); - $this->messageMapper->expects(self::never()) - ->method('updateBulk'); + $this->calendarManager->expects(self::once()) + ->method('handleIMipRequest') + ->with('principals/users/vincent', + 'pam@stardew-bus-service.com', + $account->getEmail(), + $imapMessage->scheduling[0]['contents']); + $this->messageMapper->expects(self::once()) + ->method('updateImipData'); $this->service->process(); } @@ -349,8 +351,6 @@ public function testIsReply(): void { 'pam@stardew-bus-service.com', $account->getEmail(), $imapMessage->scheduling[0]['contents']); - $this->calendarManager->expects(self::never()) - ->method('handleIMipCancel'); $this->messageMapper->expects(self::once()) ->method('updateImipData'); From 009b75f6ae8352ab0f49a9e1f58509e5748af41f Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Tue, 17 Sep 2024 11:14:37 -0400 Subject: [PATCH 2/4] fixup! feat: add iMip Request Handling Signed-off-by: SebastianKrupinski --- lib/Service/IMipService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/IMipService.php b/lib/Service/IMipService.php index a8c48dfc63..2769409402 100644 --- a/lib/Service/IMipService.php +++ b/lib/Service/IMipService.php @@ -135,7 +135,7 @@ public function process(): void { $sender = $imapMessage->getFrom()->first()->getEmail(); $recipient = $account->getEmail(); foreach ($imapMessage->scheduling as $schedulingInfo) { // an IMAP message could contain more than one iMIP object - if ($schedulingInfo['method'] === 'REQUEST') { + if ($schedulingInfo['method'] === 'REQUEST' && function_exists($this->calendarManager->handleIMipRequest)) { $processed = $this->calendarManager->handleIMipRequest($principalUri, $sender, $recipient, $schedulingInfo['contents']); $message->setImipProcessed($processed); $message->setImipError(!$processed); From 2d15a087d822656f30a6bdf993c1966ab2c57654 Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Tue, 17 Sep 2024 11:29:02 -0400 Subject: [PATCH 3/4] fixup! feat: add iMip Request Handling Signed-off-by: SebastianKrupinski --- lib/Service/IMipService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/IMipService.php b/lib/Service/IMipService.php index 2769409402..f84270c8ae 100644 --- a/lib/Service/IMipService.php +++ b/lib/Service/IMipService.php @@ -135,7 +135,7 @@ public function process(): void { $sender = $imapMessage->getFrom()->first()->getEmail(); $recipient = $account->getEmail(); foreach ($imapMessage->scheduling as $schedulingInfo) { // an IMAP message could contain more than one iMIP object - if ($schedulingInfo['method'] === 'REQUEST' && function_exists($this->calendarManager->handleIMipRequest)) { + if ($schedulingInfo['method'] === 'REQUEST' && function_exists($this->calendarManager->handleIMipRequest())) { $processed = $this->calendarManager->handleIMipRequest($principalUri, $sender, $recipient, $schedulingInfo['contents']); $message->setImipProcessed($processed); $message->setImipError(!$processed); From 9f416981838d87c48b7b1d07af2270a7ebb0629b Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Tue, 24 Sep 2024 16:09:07 -0400 Subject: [PATCH 4/4] fixup! feat: add iMip Request Handling Signed-off-by: SebastianKrupinski --- lib/Service/IMipService.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Service/IMipService.php b/lib/Service/IMipService.php index f84270c8ae..f2d501ef75 100644 --- a/lib/Service/IMipService.php +++ b/lib/Service/IMipService.php @@ -135,7 +135,7 @@ public function process(): void { $sender = $imapMessage->getFrom()->first()->getEmail(); $recipient = $account->getEmail(); foreach ($imapMessage->scheduling as $schedulingInfo) { // an IMAP message could contain more than one iMIP object - if ($schedulingInfo['method'] === 'REQUEST' && function_exists($this->calendarManager->handleIMipRequest())) { + if ($schedulingInfo['method'] === 'REQUEST' && method_exists($this->calendarManager, 'handleIMipRequest')) { $processed = $this->calendarManager->handleIMipRequest($principalUri, $sender, $recipient, $schedulingInfo['contents']); $message->setImipProcessed($processed); $message->setImipError(!$processed);