-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
feat: mail provider settings #48134
Open
SebastianKrupinski
wants to merge
9
commits into
master
Choose a base branch
from
feat/mail-provider-settings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+262
−21
Open
feat: mail provider settings #48134
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
be5187c
feat: mail provider settings
SebastianKrupinski 8236259
fixup! feat: mail provider settings
SebastianKrupinski b58b393
fixup! feat: mail provider settings
SebastianKrupinski 054ec51
fixup! feat: mail provider settings
SebastianKrupinski 2bb475b
fixup! feat: mail provider settings
SebastianKrupinski 79b1202
fixup! feat: mail provider settings
SebastianKrupinski 36ca7e6
fixup! feat: mail provider settings
SebastianKrupinski 23b3824
fixup! feat: mail provider settings
SebastianKrupinski 293cc53
fixup! feat: mail provider settings
SebastianKrupinski 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 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 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 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 |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
use OCA\DAV\CalDAV\Schedule\IMipService; | ||
use OCP\AppFramework\Utility\ITimeFactory; | ||
use OCP\Defaults; | ||
use OCP\IConfig; | ||
use OCP\IAppConfig; | ||
use OCP\IUser; | ||
use OCP\IUserSession; | ||
use OCP\Mail\IAttachment; | ||
|
@@ -52,7 +52,7 @@ class IMipPluginTest extends TestCase { | |
/** @var ITimeFactory|MockObject */ | ||
private $timeFactory; | ||
|
||
/** @var IConfig|MockObject */ | ||
/** @var IAppConfig|MockObject */ | ||
private $config; | ||
|
||
/** @var IUserSession|MockObject */ | ||
|
@@ -105,7 +105,7 @@ protected function setUp(): void { | |
$this->timeFactory = $this->createMock(ITimeFactory::class); | ||
$this->timeFactory->method('getTime')->willReturn(1496912528); // 2017-01-01 | ||
|
||
$this->config = $this->createMock(IConfig::class); | ||
$this->config = $this->createMock(IAppConfig::class); | ||
|
||
$this->user = $this->createMock(IUser::class); | ||
|
||
|
@@ -243,7 +243,7 @@ public function testParsingSingle(): void { | |
->method('getAttendeeRsvpOrReqForParticipant') | ||
->willReturn(true); | ||
$this->config->expects(self::once()) | ||
->method('getAppValue') | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('yes'); | ||
$this->service->expects(self::once()) | ||
|
@@ -341,7 +341,7 @@ public function testAttendeeIsResource(): void { | |
$this->service->expects(self::never()) | ||
->method('getAttendeeRsvpOrReqForParticipant'); | ||
$this->config->expects(self::never()) | ||
->method('getAppValue'); | ||
->method('getValueString'); | ||
$this->service->expects(self::never()) | ||
->method('createInvitationToken'); | ||
$this->service->expects(self::never()) | ||
|
@@ -447,7 +447,7 @@ public function testParsingRecurrence(): void { | |
->method('getAttendeeRsvpOrReqForParticipant') | ||
->willReturn(true); | ||
$this->config->expects(self::once()) | ||
->method('getAppValue') | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('yes'); | ||
$this->service->expects(self::once()) | ||
|
@@ -578,7 +578,7 @@ public function testFailedDelivery(): void { | |
->method('getAttendeeRsvpOrReqForParticipant') | ||
->willReturn(true); | ||
$this->config->expects(self::once()) | ||
->method('getAppValue') | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('yes'); | ||
$this->service->expects(self::once()) | ||
|
@@ -633,7 +633,7 @@ public function testMailProviderSend(): void { | |
]; | ||
// construct system config mock returns | ||
$this->config->expects(self::once()) | ||
->method('getAppValue') | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('yes'); | ||
// construct user mock returns | ||
|
@@ -708,6 +708,113 @@ public function testMailProviderSend(): void { | |
$this->assertEquals('1.1', $message->getScheduleStatus()); | ||
} | ||
|
||
public function testMailProviderDisabled(): 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' => 'Frodo']); | ||
$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' => 'Frodo']); | ||
$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'); | ||
$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') | ||
->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($atnd); | ||
$this->service->expects(self::once()) | ||
->method('isRoomOrResource') | ||
->with($atnd) | ||
->willReturn(false); | ||
$this->service->expects(self::once()) | ||
->method('buildBodyData') | ||
->with($newVevent, $oldVEvent) | ||
->willReturn($data); | ||
$this->user->expects(self::any()) | ||
->method('getUID') | ||
->willReturn('user1'); | ||
$this->user->expects(self::any()) | ||
->method('getDisplayName') | ||
->willReturn('Mr. Wizard'); | ||
$this->userSession->expects(self::any()) | ||
->method('getUser') | ||
->willReturn($this->user); | ||
$this->service->expects(self::once()) | ||
->method('getFrom'); | ||
$this->service->expects(self::once()) | ||
->method('addSubjectAndHeading') | ||
->with($this->emailTemplate, 'request', 'Mr. Wizard', 'Fellowship meeting without (!) Boromir', true); | ||
$this->service->expects(self::once()) | ||
->method('addBulletList') | ||
->with($this->emailTemplate, $newVevent, $data); | ||
$this->service->expects(self::once()) | ||
->method('getAttendeeRsvpOrReqForParticipant') | ||
->willReturn(true); | ||
$this->config->expects(self::once()) | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('yes'); | ||
$this->config->expects(self::once()) | ||
->method('getValueInt') | ||
->with('core', 'mail_providers_disabled', 0) | ||
->willReturn(1); | ||
$this->service->expects(self::once()) | ||
->method('createInvitationToken') | ||
->with($message, $newVevent, 1496912700) | ||
->willReturn('token'); | ||
$this->service->expects(self::once()) | ||
->method('addResponseButtons') | ||
->with($this->emailTemplate, 'token'); | ||
$this->service->expects(self::once()) | ||
->method('addMoreOptionsButton') | ||
->with($this->emailTemplate, 'token'); | ||
$this->mailer->expects(self::once()) | ||
->method('send') | ||
->willReturn([]); | ||
$this->plugin->schedule($message); | ||
$this->assertEquals('1.1', $message->getScheduleStatus()); | ||
} | ||
|
||
public function testNoOldEvent(): void { | ||
$message = new Message(); | ||
$message->method = 'REQUEST'; | ||
|
@@ -779,7 +886,7 @@ public function testNoOldEvent(): void { | |
->method('getAttendeeRsvpOrReqForParticipant') | ||
->willReturn(true); | ||
$this->config->expects(self::once()) | ||
->method('getAppValue') | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('yes'); | ||
$this->service->expects(self::once()) | ||
|
@@ -872,7 +979,7 @@ public function testNoButtons(): void { | |
->method('getAttendeeRsvpOrReqForParticipant') | ||
->willReturn(true); | ||
$this->config->expects(self::once()) | ||
->method('getAppValue') | ||
->method('getValueString') | ||
->with('dav', 'invitation_link_recipients', 'yes') | ||
->willReturn('no'); | ||
$this->service->expects(self::never()) | ||
|
This file contains 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 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 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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a boolean?
I would also recommend using mail_providers_enabled true/false rather than mail_providers_disabled true/false because it's easier to read.
Example:
if (!$this->config->getValueBool('core', 'mail_providers_disabled', false))
vs.
if ($this->config->getValueBool('core', 'mail_providers_enabled', true))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The declarative setting does work with boolean properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, therefore I suggested it ;)