Merge pull request #20981 from owncloud/issue-19848-multiple-emails-for-sharelink

Allow sending a share email to multiple users
This commit is contained in:
Thomas Müller 2015-12-07 15:17:19 +01:00
commit a9e5faf7d0
2 changed files with 22 additions and 4 deletions

View File

@ -176,10 +176,12 @@ class MailNotifications {
$subject = (string)$this->l->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]); $subject = (string)$this->l->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]);
list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration); list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration);
$recipient = str_replace([', ', '; ', ',', ';', ' '], ',', $recipient);
$recipients = explode(',', $recipient);
try { try {
$message = $this->mailer->createMessage(); $message = $this->mailer->createMessage();
$message->setSubject($subject); $message->setSubject($subject);
$message->setTo([$recipient]); $message->setTo($recipients);
$message->setHtmlBody($htmlBody); $message->setHtmlBody($htmlBody);
$message->setPlainBody($textBody); $message->setPlainBody($textBody);
$message->setFrom([ $message->setFrom([

View File

@ -123,7 +123,23 @@ class MailNotificationsTest extends \Test\TestCase {
$this->assertSame([], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600)); $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', ['lukas@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']],
['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', ['lukas@owncloud.com', 'nickvergessen@owncloud.com']],
];
}
/**
* @dataProvider dataSendLinkShareMailWithReplyTo
* @param string $to
* @param array $expectedTo
*/
public function testSendLinkShareMailWithReplyTo($to, array $expectedTo) {
$message = $this->getMockBuilder('\OC\Mail\Message') $message = $this->getMockBuilder('\OC\Mail\Message')
->disableOriginalConstructor()->getMock(); ->disableOriginalConstructor()->getMock();
@ -134,7 +150,7 @@ class MailNotificationsTest extends \Test\TestCase {
$message $message
->expects($this->once()) ->expects($this->once())
->method('setTo') ->method('setTo')
->with(['lukas@owncloud.com']); ->with($expectedTo);
$message $message
->expects($this->once()) ->expects($this->once())
->method('setHtmlBody'); ->method('setHtmlBody');
@ -167,7 +183,7 @@ class MailNotificationsTest extends \Test\TestCase {
$this->logger, $this->logger,
$this->defaults $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() { public function testSendLinkShareMailException() {