-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
[stable27] fix(scheduling): don't send iMIP emails to rooms / resources #41315
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,6 +45,7 @@ | |
| use Sabre\VObject\Component\VCalendar; | ||
| use Sabre\VObject\Component\VEvent; | ||
| use Sabre\VObject\ITip\Message; | ||
| use Sabre\VObject\Property; | ||
| use Test\TestCase; | ||
| use function array_merge; | ||
|
|
||
|
|
@@ -183,6 +184,13 @@ public function testParsingSingle(): void { | |
| 'meeting_title' => 'Fellowship meeting without (!) Boromir', | ||
| 'attendee_name' => '[email protected]' | ||
| ]; | ||
| $attendees = $newVevent->select('ATTENDEE'); | ||
| $atnd = ''; | ||
| foreach ($attendees as $attendee) { | ||
| if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { | ||
| $atnd = $attendee; | ||
| } | ||
| } | ||
| $this->plugin->setVCalendar($oldVCalendar); | ||
| $this->service->expects(self::once()) | ||
| ->method('getLastOccurrence') | ||
|
|
@@ -194,6 +202,14 @@ public function testParsingSingle(): void { | |
| $this->eventComparisonService->expects(self::once()) | ||
| ->method('findModified') | ||
| ->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); | ||
| $this->service->expects(self::once()) | ||
| ->method('getCurrentAttendee') | ||
| ->with($message) | ||
| ->willReturn($atnd); | ||
| $this->service->expects(self::once()) | ||
| ->method('isRoomOrResource') | ||
| ->with($atnd) | ||
| ->willReturn(false); | ||
| $this->service->expects(self::once()) | ||
| ->method('buildBodyData') | ||
| ->with($newVevent, $oldVEvent) | ||
|
|
@@ -232,6 +248,91 @@ public function testParsingSingle(): void { | |
| $this->assertEquals('1.1', $message->getScheduleStatus()); | ||
| } | ||
|
|
||
| public function testAttendeeIsResource(): void { | ||
| $message = new Message(); | ||
| $message->method = 'REQUEST'; | ||
| $newVCalendar = new VCalendar(); | ||
| $newVevent = new VEvent($newVCalendar, 'one', array_merge([ | ||
| 'UID' => 'uid-1234', | ||
| 'SEQUENCE' => 1, | ||
| 'SUMMARY' => 'Fellowship meeting without (!) Boromir', | ||
| 'DTSTART' => new \DateTime('2016-01-01 00:00:00') | ||
| ], [])); | ||
| $newVevent->add('ORGANIZER', 'mailto:[email protected]'); | ||
| $newVevent->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'The Shire', 'CUTYPE' => 'ROOM']); | ||
| $message->message = $newVCalendar; | ||
| $message->sender = 'mailto:[email protected]'; | ||
| $message->senderName = 'Mr. Wizard'; | ||
| $message->recipient = 'mailto:' . '[email protected]'; | ||
| // save the old copy in the plugin | ||
| $oldVCalendar = new VCalendar(); | ||
| $oldVEvent = new VEvent($oldVCalendar, 'one', [ | ||
| 'UID' => 'uid-1234', | ||
| 'SEQUENCE' => 0, | ||
| 'SUMMARY' => 'Fellowship meeting', | ||
| 'DTSTART' => new \DateTime('2016-01-01 00:00:00') | ||
| ]); | ||
| $oldVEvent->add('ORGANIZER', 'mailto:[email protected]'); | ||
| $oldVEvent->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE', 'CN' => 'The Shire', 'CUTYPE' => 'ROOM']); | ||
| $oldVEvent->add('ATTENDEE', 'mailto:' . '[email protected]', ['RSVP' => 'TRUE']); | ||
| $oldVCalendar->add($oldVEvent); | ||
| $data = ['invitee_name' => 'Mr. Wizard', | ||
| 'meeting_title' => 'Fellowship meeting without (!) Boromir', | ||
| 'attendee_name' => '[email protected]' | ||
| ]; | ||
| $attendees = $newVevent->select('ATTENDEE'); | ||
| $room = ''; | ||
| foreach ($attendees as $attendee) { | ||
| if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { | ||
| $room = $attendee; | ||
| } | ||
| } | ||
| $this->plugin->setVCalendar($oldVCalendar); | ||
| $this->service->expects(self::once()) | ||
| ->method('getLastOccurrence') | ||
| ->willReturn('1496912700'); | ||
| $this->mailer->expects(self::once()) | ||
| ->method('validateMailAddress') | ||
| ->with('[email protected]') | ||
| ->willReturn(true); | ||
| $this->eventComparisonService->expects(self::once()) | ||
| ->method('findModified') | ||
| ->willReturn(['new' => [$newVevent], 'old' => [$oldVEvent]]); | ||
| $this->service->expects(self::once()) | ||
| ->method('getCurrentAttendee') | ||
| ->with($message) | ||
| ->willReturn($room); | ||
| $this->service->expects(self::once()) | ||
| ->method('isRoomOrResource') | ||
| ->with($room) | ||
| ->willReturn(true); | ||
| $this->service->expects(self::never()) | ||
| ->method('buildBodyData'); | ||
| $this->userManager->expects(self::never()) | ||
| ->method('getDisplayName'); | ||
| $this->service->expects(self::never()) | ||
| ->method('getFrom'); | ||
| $this->service->expects(self::never()) | ||
| ->method('addSubjectAndHeading'); | ||
| $this->service->expects(self::never()) | ||
| ->method('addBulletList'); | ||
| $this->service->expects(self::never()) | ||
| ->method('getAttendeeRsvpOrReqForParticipant'); | ||
| $this->config->expects(self::never()) | ||
| ->method('getAppValue'); | ||
| $this->service->expects(self::never()) | ||
| ->method('createInvitationToken'); | ||
| $this->service->expects(self::never()) | ||
| ->method('addResponseButtons'); | ||
| $this->service->expects(self::never()) | ||
| ->method('addMoreOptionsButton'); | ||
| $this->mailer->expects(self::never()) | ||
| ->method('send'); | ||
| $this->plugin->schedule($message); | ||
| $this->assertEquals('1.0', $message->getScheduleStatus()); | ||
| } | ||
|
|
||
|
|
||
| public function testParsingRecurrence(): void { | ||
| $message = new Message(); | ||
| $message->method = 'REQUEST'; | ||
|
|
@@ -274,6 +375,13 @@ public function testParsingRecurrence(): void { | |
| 'meeting_title' => 'Elevenses', | ||
| 'attendee_name' => '[email protected]' | ||
| ]; | ||
| $attendees = $newVevent->select('ATTENDEE'); | ||
| $atnd = ''; | ||
| foreach ($attendees as $attendee) { | ||
| if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { | ||
| $atnd = $attendee; | ||
| } | ||
| } | ||
| $this->plugin->setVCalendar($oldVCalendar); | ||
| $this->service->expects(self::once()) | ||
| ->method('getLastOccurrence') | ||
|
|
@@ -285,6 +393,14 @@ public function testParsingRecurrence(): void { | |
| $this->eventComparisonService->expects(self::once()) | ||
| ->method('findModified') | ||
| ->willReturn(['old' => [] ,'new' => [$newVevent]]); | ||
| $this->service->expects(self::once()) | ||
| ->method('getCurrentAttendee') | ||
| ->with($message) | ||
| ->willReturn($atnd); | ||
| $this->service->expects(self::once()) | ||
| ->method('isRoomOrResource') | ||
| ->with($atnd) | ||
| ->willReturn(false); | ||
| $this->service->expects(self::once()) | ||
| ->method('buildBodyData') | ||
| ->with($newVevent, null) | ||
|
|
@@ -384,6 +500,13 @@ public function testFailedDelivery(): void { | |
| 'meeting_title' => 'Fellowship meeting without (!) Boromir', | ||
| 'attendee_name' => '[email protected]' | ||
| ]; | ||
| $attendees = $newVevent->select('ATTENDEE'); | ||
| $atnd = ''; | ||
| foreach ($attendees as $attendee) { | ||
| if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { | ||
| $atnd = $attendee; | ||
| } | ||
| } | ||
| $this->plugin->setVCalendar($oldVcalendar); | ||
| $this->service->expects(self::once()) | ||
| ->method('getLastOccurrence') | ||
|
|
@@ -395,6 +518,14 @@ public function testFailedDelivery(): void { | |
| $this->eventComparisonService->expects(self::once()) | ||
| ->method('findModified') | ||
| ->willReturn(['old' => [] ,'new' => [$newVevent]]); | ||
| $this->service->expects(self::once()) | ||
| ->method('getCurrentAttendee') | ||
| ->with($message) | ||
| ->willReturn($atnd); | ||
| $this->service->expects(self::once()) | ||
| ->method('isRoomOrResource') | ||
| ->with($atnd) | ||
| ->willReturn(false); | ||
| $this->service->expects(self::once()) | ||
| ->method('buildBodyData') | ||
| ->with($newVevent, null) | ||
|
|
@@ -458,7 +589,13 @@ public function testNoOldEvent(): void { | |
| 'meeting_title' => 'Fellowship meeting', | ||
| 'attendee_name' => '[email protected]' | ||
| ]; | ||
|
|
||
| $attendees = $newVevent->select('ATTENDEE'); | ||
| $atnd = ''; | ||
| foreach ($attendees as $attendee) { | ||
| if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { | ||
| $atnd = $attendee; | ||
| } | ||
| } | ||
| $this->service->expects(self::once()) | ||
| ->method('getLastOccurrence') | ||
| ->willReturn('1496912700'); | ||
|
|
@@ -470,6 +607,14 @@ public function testNoOldEvent(): void { | |
| ->method('findModified') | ||
| ->with($newVCalendar, null) | ||
| ->willReturn(['old' => [] ,'new' => [$newVevent]]); | ||
| $this->service->expects(self::once()) | ||
| ->method('getCurrentAttendee') | ||
| ->with($message) | ||
| ->willReturn($atnd); | ||
| $this->service->expects(self::once()) | ||
| ->method('isRoomOrResource') | ||
| ->with($atnd) | ||
| ->willReturn(false); | ||
| $this->service->expects(self::once()) | ||
| ->method('buildBodyData') | ||
| ->with($newVevent, null) | ||
|
|
@@ -530,7 +675,13 @@ public function testNoButtons(): void { | |
| 'meeting_title' => 'Fellowship meeting', | ||
| 'attendee_name' => '[email protected]' | ||
| ]; | ||
|
|
||
| $attendees = $newVevent->select('ATTENDEE'); | ||
| $atnd = ''; | ||
| foreach ($attendees as $attendee) { | ||
| if (strcasecmp($attendee->getValue(), $message->recipient) === 0) { | ||
| $atnd = $attendee; | ||
| } | ||
| } | ||
| $this->service->expects(self::once()) | ||
| ->method('getLastOccurrence') | ||
| ->willReturn('1496912700'); | ||
|
|
@@ -542,6 +693,14 @@ public function testNoButtons(): void { | |
| ->method('findModified') | ||
| ->with($newVCalendar, null) | ||
| ->willReturn(['old' => [] ,'new' => [$newVevent]]); | ||
| $this->service->expects(self::once()) | ||
| ->method('getCurrentAttendee') | ||
| ->with($message) | ||
| ->willReturn($atnd); | ||
| $this->service->expects(self::once()) | ||
| ->method('isRoomOrResource') | ||
| ->with($atnd) | ||
| ->willReturn(false); | ||
| $this->service->expects(self::once()) | ||
| ->method('buildBodyData') | ||
| ->with($newVevent, null) | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.