summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-04-11 17:32:48 -0500
committerMorris Jobke <hey@morrisjobke.de>2017-04-11 17:32:48 -0500
commit8fa5141aaa346fc21198ad59c315eb99a8b8e48a (patch)
treeb88273d191e11f9541609f08935c2956c85346aa
parent6bd1c50dc32ccc208723ef08af72b8bfe99b58bb (diff)
downloadnextcloud-server-8fa5141aaa346fc21198ad59c315eb99a8b8e48a.tar.gz
nextcloud-server-8fa5141aaa346fc21198ad59c315eb99a8b8e48a.zip
Removes unused code for link share emails
* now handled by sharebymail app * see https://github.com/nextcloud/server/pull/657 Signed-off-by: Morris Jobke <hey@morrisjobke.de>
-rw-r--r--core/templates/altmail.php13
-rw-r--r--core/templates/mail.php38
-rw-r--r--lib/private/Share/MailNotifications.php68
-rw-r--r--tests/lib/Share/MailNotificationsTest.php124
4 files changed, 0 insertions, 243 deletions
diff --git a/core/templates/altmail.php b/core/templates/altmail.php
deleted file mode 100644
index 38531d109b7..00000000000
--- a/core/templates/altmail.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-print_unescaped($l->t("Hey there,\n\njust letting you know that %s shared %s with you.\nView it: %s\n\n", array($_['user_displayname'], $_['filename'], $_['link'])));
-if ( isset($_['expiration']) ) {
- print_unescaped($l->t("The share will expire on %s.", array($_['expiration'])));
- print_unescaped("\n\n");
-}
-// TRANSLATORS term at the end of a mail
-p($l->t("Cheers!"));
-?>
-
---
-<?php p($theme->getName() . ' - ' . $theme->getSlogan()); ?>
-<?php print_unescaped("\n".$theme->getBaseUrl());
diff --git a/core/templates/mail.php b/core/templates/mail.php
deleted file mode 100644
index cda33490e85..00000000000
--- a/core/templates/mail.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<table cellspacing="0" cellpadding="0" border="0" width="100%">
-<tr><td>
-<table cellspacing="0" cellpadding="0" border="0" width="600px">
-<tr>
-<td colspan="2" bgcolor="<?php p($theme->getColorPrimary());?>">
-<img src="<?php p(\OC::$server->getURLGenerator()->getAbsoluteURL(image_path('', 'logo-mail.png'))); ?>" alt="<?php p($theme->getName()); ?>"/>
-</td>
-</tr>
-<tr><td colspan="2">&nbsp;</td></tr>
-<tr>
-<td width="20px">&nbsp;</td>
-<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">
-<?php
-print_unescaped($l->t('Hey there,<br><br>just letting you know that %s shared <strong>%s</strong> with you.<br><a href="%s">View it!</a><br><br>', array($_['user_displayname'], $_['filename'], $_['link'])));
-if ( isset($_['expiration']) ) {
- p($l->t("The share will expire on %s.", array($_['expiration'])));
- print_unescaped('<br><br>');
-}
-// TRANSLATORS term at the end of a mail
-p($l->t('Cheers!'));
-?>
-</td>
-</tr>
-<tr><td colspan="2">&nbsp;</td></tr>
-<tr>
-<td width="20px">&nbsp;</td>
-<td style="font-weight:normal; font-size:0.8em; line-height:1.2em; font-family:verdana,'arial',sans;">--<br>
-<?php p($theme->getName()); ?> -
-<?php p($theme->getSlogan()); ?>
-<br><a href="<?php p($theme->getBaseUrl()); ?>"><?php p($theme->getBaseUrl());?></a>
-</td>
-</tr>
-<tr>
-<td colspan="2">&nbsp;</td>
-</tr>
-</table>
-</td></tr>
-</table>
diff --git a/lib/private/Share/MailNotifications.php b/lib/private/Share/MailNotifications.php
index 1ea053fc499..e10389e77b9 100644
--- a/lib/private/Share/MailNotifications.php
+++ b/lib/private/Share/MailNotifications.php
@@ -86,72 +86,4 @@ class MailNotifications {
$this->replyTo = $this->user->getEMailAddress();
$this->senderDisplayName = $this->user->getDisplayName();
}
-
- /**
- * inform recipient about public link share
- *
- * @param string $recipient recipient email address
- * @param string $filename the shared file
- * @param string $link the public link
- * @param int $expiration expiration date (timestamp)
- * @return string[] $result of failed recipients
- */
- public function sendLinkShareMail($recipient, $filename, $link, $expiration) {
- $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($recipients);
- $message->setHtmlBody($htmlBody);
- $message->setPlainBody($textBody);
- $message->setFrom([
- Util::getDefaultEmailAddress('sharing-noreply') =>
- (string)$this->l->t('%s via %s', [
- $this->senderDisplayName,
- $this->defaults->getName()
- ]),
- ]);
- if(!is_null($this->replyTo)) {
- $message->setReplyTo([$this->replyTo]);
- }
-
- return $this->mailer->send($message);
- } catch (\Exception $e) {
- $this->logger->error("Can't send mail with public link to $recipient: ".$e->getMessage(), ['app' => 'sharing']);
- return [$recipient];
- }
- }
-
- /**
- * create mail body for plain text and html mail
- *
- * @param string $filename the shared file
- * @param string $link link to the shared file
- * @param int $expiration expiration date (timestamp)
- * @param string $prefix prefix of mail template files
- * @return array an array of the html mail body and the plain text mail body
- */
- private function createMailBody($filename, $link, $expiration, $prefix = '') {
- $formattedDate = $expiration ? $this->l->l('date', $expiration) : null;
-
- $html = new \OC_Template('core', $prefix . 'mail', '');
- $html->assign ('link', $link);
- $html->assign ('user_displayname', $this->senderDisplayName);
- $html->assign ('filename', $filename);
- $html->assign('expiration', $formattedDate);
- $htmlMail = $html->fetchPage();
-
- $plainText = new \OC_Template('core', $prefix . 'altmail', '');
- $plainText->assign ('link', $link);
- $plainText->assign ('user_displayname', $this->senderDisplayName);
- $plainText->assign ('filename', $filename);
- $plainText->assign('expiration', $formattedDate);
- $plainTextMail = $plainText->fetchPage();
-
- return [$htmlMail, $plainTextMail];
- }
}
diff --git a/tests/lib/Share/MailNotificationsTest.php b/tests/lib/Share/MailNotificationsTest.php
index 6fae8eb72fd..2759ee04946 100644
--- a/tests/lib/Share/MailNotificationsTest.php
+++ b/tests/lib/Share/MailNotificationsTest.php
@@ -84,130 +84,6 @@ class MailNotificationsTest extends \Test\TestCase {
}
- public function testSendLinkShareMailWithoutReplyTo() {
- $message = $this->getMockBuilder('\OC\Mail\Message')
- ->disableOriginalConstructor()->getMock();
-
- $message
- ->expects($this->once())
- ->method('setSubject')
- ->with('TestUser shared »MyFile« with you');
- $message
- ->expects($this->once())
- ->method('setTo')
- ->with(['lukas@owncloud.com']);
- $message
- ->expects($this->once())
- ->method('setHtmlBody');
- $message
- ->expects($this->once())
- ->method('setPlainBody');
- $message
- ->expects($this->once())
- ->method('setFrom')
- ->with([\OCP\Util::getDefaultEmailAddress('sharing-noreply') => 'TestUser via UnitTestCloud']);
-
- $this->mailer
- ->expects($this->once())
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->once())
- ->method('send')
- ->with($message)
- ->will($this->returnValue([]));
-
- $mailNotifications = new MailNotifications(
- $this->user,
- $this->l10n,
- $this->mailer,
- $this->logger,
- $this->defaults,
- $this->urlGenerator
- );
-
- $this->assertSame([], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
- }
-
- 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')
- ->disableOriginalConstructor()->getMock();
-
- $message
- ->expects($this->once())
- ->method('setSubject')
- ->with('TestUser shared »MyFile« with you');
- $message
- ->expects($this->once())
- ->method('setTo')
- ->with($expectedTo);
- $message
- ->expects($this->once())
- ->method('setHtmlBody');
- $message
- ->expects($this->once())
- ->method('setPlainBody');
- $message
- ->expects($this->once())
- ->method('setFrom')
- ->with([\OCP\Util::getDefaultEmailAddress('sharing-noreply') => 'TestUser via UnitTestCloud']);
- $message
- ->expects($this->once())
- ->method('setReplyTo')
- ->with(['sharer@owncloud.com']);
-
- $this->mailer
- ->expects($this->once())
- ->method('createMessage')
- ->will($this->returnValue($message));
- $this->mailer
- ->expects($this->once())
- ->method('send')
- ->with($message)
- ->will($this->returnValue([]));
-
- $mailNotifications = new MailNotifications(
- $this->user,
- $this->l10n,
- $this->mailer,
- $this->logger,
- $this->defaults,
- $this->urlGenerator
- );
- $this->assertSame([], $mailNotifications->sendLinkShareMail($to, 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
- }
-
- public function testSendLinkShareMailException() {
- $this->setupMailerMock('TestUser shared »MyFile« with you', ['lukas@owncloud.com']);
-
- $mailNotifications = new MailNotifications(
- $this->user,
- $this->l10n,
- $this->mailer,
- $this->logger,
- $this->defaults,
- $this->urlGenerator
- );
-
- $this->assertSame(['lukas@owncloud.com'], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
- }
-
/**
* @param string $subject
*/