Skip to content
Snippets Groups Projects
Commit 5b874137 authored by Joas Schilling's avatar Joas Schilling
Browse files

Allow sending a share email to multiple users

parent 88494627
No related branches found
No related tags found
No related merge requests found
......@@ -176,10 +176,12 @@ class MailNotifications {
$subject = (string)$this->l->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]);
list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration);
$recipient = str_replace([', ', '; ', ',', ';', ' '], ',', $recipient);
$recipients = explode(',', $recipient);
try {
$message = $this->mailer->createMessage();
$message->setSubject($subject);
$message->setTo([$recipient]);
$message->setTo($recipients);
$message->setHtmlBody($htmlBody);
$message->setPlainBody($textBody);
$message->setFrom([
......
......@@ -123,7 +123,21 @@ class MailNotificationsTest extends \Test\TestCase {
$this->assertSame([], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
}
public function testSendLinkShareMailWithReplyTo() {
public function dataSendLinkShareMailWithReplyTo() {
return [
['lukas@owncloud.com nickvergessen@owncloud.com'],
['lukas@owncloud.com,nickvergessen@owncloud.com'],
['lukas@owncloud.com, nickvergessen@owncloud.com'],
['lukas@owncloud.com;nickvergessen@owncloud.com'],
['lukas@owncloud.com; nickvergessen@owncloud.com'],
];
}
/**
* @dataProvider dataSendLinkShareMailWithReplyTo
* @param string $to
*/
public function testSendLinkShareMailWithReplyTo($to) {
$message = $this->getMockBuilder('\OC\Mail\Message')
->disableOriginalConstructor()->getMock();
......@@ -134,7 +148,7 @@ class MailNotificationsTest extends \Test\TestCase {
$message
->expects($this->once())
->method('setTo')
->with(['lukas@owncloud.com']);
->with(['lukas@owncloud.com', 'nickvergessen@owncloud.com']);
$message
->expects($this->once())
->method('setHtmlBody');
......@@ -167,7 +181,7 @@ class MailNotificationsTest extends \Test\TestCase {
$this->logger,
$this->defaults
);
$this->assertSame([], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
$this->assertSame([], $mailNotifications->sendLinkShareMail($to, 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
}
public function testSendLinkShareMailException() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment