Set the data from the template
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
c9af36a9ab
commit
3119fd41ce
9 changed files with 46 additions and 113 deletions
|
@ -427,9 +427,7 @@ class ShareByMailProvider implements IShareProvider {
|
|||
$emailTemplate->addFooter();
|
||||
}
|
||||
|
||||
$message->setSubject($emailTemplate->renderSubject());
|
||||
$message->setPlainBody($emailTemplate->renderText());
|
||||
$message->setHtmlBody($emailTemplate->renderHtml());
|
||||
$message->useTemplate($emailTemplate);
|
||||
$this->mailer->send($message);
|
||||
}
|
||||
|
||||
|
@ -491,9 +489,7 @@ class ShareByMailProvider implements IShareProvider {
|
|||
}
|
||||
|
||||
$message->setTo([$shareWith]);
|
||||
$message->setSubject($emailTemplate->renderSubject());
|
||||
$message->setBody($emailTemplate->renderText(), 'text/plain');
|
||||
$message->setHtmlBody($emailTemplate->renderHtml());
|
||||
$message->useTemplate($emailTemplate);
|
||||
$this->mailer->send($message);
|
||||
|
||||
$this->createPasswordSendActivity($share, $shareWith, false);
|
||||
|
@ -547,9 +543,7 @@ class ShareByMailProvider implements IShareProvider {
|
|||
$message->setFrom([$initiatorEMailAddress => $initiatorDisplayName]);
|
||||
}
|
||||
$message->setTo([$initiatorEMailAddress => $initiatorDisplayName]);
|
||||
$message->setSubject($emailTemplate->renderSubject());
|
||||
$message->setBody($emailTemplate->renderText(), 'text/plain');
|
||||
$message->setHtmlBody($emailTemplate->renderHtml());
|
||||
$message->useTemplate($emailTemplate);
|
||||
$this->mailer->send($message);
|
||||
|
||||
$this->createPasswordSendActivity($share, $shareWith, true);
|
||||
|
|
|
@ -835,26 +835,14 @@ class ShareByMailProviderTest extends TestCase {
|
|||
->expects($this->once())
|
||||
->method('addFooter')
|
||||
->with('UnitTestCloud - Testing like 1990');
|
||||
$message
|
||||
$template
|
||||
->expects($this->once())
|
||||
->method('setSubject')
|
||||
->willReturn('Mrs. Owner User shared »file.txt« with you');
|
||||
$template
|
||||
->expects($this->once())
|
||||
->method('renderText')
|
||||
->willReturn('Text Render');
|
||||
->with('Mrs. Owner User shared »file.txt« with you');
|
||||
$message
|
||||
->expects($this->once())
|
||||
->method('setPlainBody')
|
||||
->with('Text Render');
|
||||
$template
|
||||
->expects($this->once())
|
||||
->method('renderHtml')
|
||||
->willReturn('HTML Render');
|
||||
$message
|
||||
->expects($this->once())
|
||||
->method('setHtmlBody')
|
||||
->with('HTML Render');
|
||||
->method('useTemplate')
|
||||
->with($template);
|
||||
$this->mailer
|
||||
->expects($this->once())
|
||||
->method('send')
|
||||
|
@ -936,26 +924,14 @@ class ShareByMailProviderTest extends TestCase {
|
|||
->expects($this->once())
|
||||
->method('addFooter')
|
||||
->with('');
|
||||
$message
|
||||
$template
|
||||
->expects($this->once())
|
||||
->method('setSubject')
|
||||
->willReturn('Mr. Initiator User shared »file.txt« with you');
|
||||
$template
|
||||
->expects($this->once())
|
||||
->method('renderText')
|
||||
->willReturn('Text Render');
|
||||
->with('Mr. Initiator User shared »file.txt« with you');
|
||||
$message
|
||||
->expects($this->once())
|
||||
->method('setPlainBody')
|
||||
->with('Text Render');
|
||||
$template
|
||||
->expects($this->once())
|
||||
->method('renderHtml')
|
||||
->willReturn('HTML Render');
|
||||
$message
|
||||
->expects($this->once())
|
||||
->method('setHtmlBody')
|
||||
->with('HTML Render');
|
||||
->method('useTemplate')
|
||||
->with($template);
|
||||
$this->mailer
|
||||
->expects($this->once())
|
||||
->method('send')
|
||||
|
|
|
@ -328,10 +328,8 @@ class LostController extends Controller {
|
|||
try {
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo([$email => $user->getUID()]);
|
||||
$message->setSubject($emailTemplate->renderSubject());
|
||||
$message->setPlainBody($emailTemplate->renderText());
|
||||
$message->setHtmlBody($emailTemplate->renderHtml());
|
||||
$message->setFrom([$this->from => $this->defaults->getName()]);
|
||||
$message->useTemplate($emailTemplate);
|
||||
$this->mailer->send($message);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception($this->l10n->t(
|
||||
|
|
|
@ -750,9 +750,7 @@ class Manager implements IManager {
|
|||
$emailTemplate->addFooter();
|
||||
}
|
||||
|
||||
$message->setSubject($emailTemplate->renderSubject());
|
||||
$message->setPlainBody($emailTemplate->renderText());
|
||||
$message->setHtmlBody($emailTemplate->renderHtml());
|
||||
$message->useTemplate($emailTemplate);
|
||||
$this->mailer->send($message);
|
||||
}
|
||||
|
||||
|
|
|
@ -159,9 +159,7 @@ class MailSettingsController extends Controller {
|
|||
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo([$email => $displayName]);
|
||||
$message->setSubject($template->renderSubject());
|
||||
$message->setHtmlBody($template->renderHtml());
|
||||
$message->setPlainBody($template->renderText());
|
||||
$message->useTemplate($template);
|
||||
$errors = $this->mailer->send($message);
|
||||
if (!empty($errors)) {
|
||||
throw new \RuntimeException($this->l10n->t('Email could not be sent. Check your mail server log'));
|
||||
|
|
|
@ -132,10 +132,7 @@ class Hooks {
|
|||
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo([$user->getEMailAddress() => $user->getDisplayName()]);
|
||||
$message->setSubject($template->renderSubject());
|
||||
$message->setBody($template->renderText(), 'text/plain');
|
||||
$message->setHtmlBody($template->renderHtml());
|
||||
|
||||
$message->useTemplate($template);
|
||||
$this->mailer->send($message);
|
||||
}
|
||||
}
|
||||
|
@ -208,10 +205,7 @@ class Hooks {
|
|||
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo([$oldMailAddress => $user->getDisplayName()]);
|
||||
$message->setSubject($template->renderSubject());
|
||||
$message->setBody($template->renderText(), 'text/plain');
|
||||
$message->setHtmlBody($template->renderHtml());
|
||||
|
||||
$message->useTemplate($template);
|
||||
$this->mailer->send($message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,10 +160,8 @@ class NewUserMailHelper {
|
|||
IEMailTemplate $emailTemplate) {
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo([$user->getEMailAddress() => $user->getDisplayName()]);
|
||||
$message->setSubject($emailTemplate->renderSubject());
|
||||
$message->setHtmlBody($emailTemplate->renderHtml());
|
||||
$message->setPlainBody($emailTemplate->renderText());
|
||||
$message->setFrom([$this->fromAddress => $this->themingDefaults->getName()]);
|
||||
$message->useTemplate($emailTemplate);
|
||||
$this->mailer->send($message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -324,20 +324,9 @@ class LostControllerTest extends \Test\TestCase {
|
|||
->with(['test@example.com' => 'ExistingUser']);
|
||||
$message
|
||||
->expects($this->at(1))
|
||||
->method('setSubject')
|
||||
->with(' password reset');
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('setPlainBody')
|
||||
->with('text body');
|
||||
$message
|
||||
->expects($this->at(3))
|
||||
->method('setHtmlBody')
|
||||
->with('HTML body');
|
||||
$message
|
||||
->expects($this->at(4))
|
||||
->method('setFrom')
|
||||
->with(['lostpassword-noreply@localhost' => null]);
|
||||
|
||||
$emailTemplate = $this->createMock(IEMailTemplate::class);
|
||||
$emailTemplate->expects($this->any())
|
||||
->method('renderHtml')
|
||||
|
@ -345,6 +334,12 @@ class LostControllerTest extends \Test\TestCase {
|
|||
$emailTemplate->expects($this->any())
|
||||
->method('renderText')
|
||||
->willReturn('text body');
|
||||
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('useTemplate')
|
||||
->with($emailTemplate);
|
||||
|
||||
$this->mailer
|
||||
->expects($this->at(0))
|
||||
->method('createEMailTemplate')
|
||||
|
@ -407,20 +402,9 @@ class LostControllerTest extends \Test\TestCase {
|
|||
->with(['test@example.com' => 'ExistingUser']);
|
||||
$message
|
||||
->expects($this->at(1))
|
||||
->method('setSubject')
|
||||
->with(' password reset');
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('setPlainBody')
|
||||
->with('text body');
|
||||
$message
|
||||
->expects($this->at(3))
|
||||
->method('setHtmlBody')
|
||||
->with('HTML body');
|
||||
$message
|
||||
->expects($this->at(4))
|
||||
->method('setFrom')
|
||||
->with(['lostpassword-noreply@localhost' => null]);
|
||||
|
||||
$emailTemplate = $this->createMock(IEMailTemplate::class);
|
||||
$emailTemplate->expects($this->any())
|
||||
->method('renderHtml')
|
||||
|
@ -428,6 +412,12 @@ class LostControllerTest extends \Test\TestCase {
|
|||
$emailTemplate->expects($this->any())
|
||||
->method('renderText')
|
||||
->willReturn('text body');
|
||||
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('useTemplate')
|
||||
->with($emailTemplate);
|
||||
|
||||
$this->mailer
|
||||
->expects($this->at(0))
|
||||
->method('createEMailTemplate')
|
||||
|
@ -484,20 +474,9 @@ class LostControllerTest extends \Test\TestCase {
|
|||
->with(['test@example.com' => 'ExistingUser']);
|
||||
$message
|
||||
->expects($this->at(1))
|
||||
->method('setSubject')
|
||||
->with(' password reset');
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('setPlainBody')
|
||||
->with('text body');
|
||||
$message
|
||||
->expects($this->at(3))
|
||||
->method('setHtmlBody')
|
||||
->with('HTML body');
|
||||
$message
|
||||
->expects($this->at(4))
|
||||
->method('setFrom')
|
||||
->with(['lostpassword-noreply@localhost' => null]);
|
||||
|
||||
$emailTemplate = $this->createMock(IEMailTemplate::class);
|
||||
$emailTemplate->expects($this->any())
|
||||
->method('renderHtml')
|
||||
|
@ -505,6 +484,12 @@ class LostControllerTest extends \Test\TestCase {
|
|||
$emailTemplate->expects($this->any())
|
||||
->method('renderText')
|
||||
->willReturn('text body');
|
||||
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('useTemplate')
|
||||
->with($emailTemplate);
|
||||
|
||||
$this->mailer
|
||||
->expects($this->at(0))
|
||||
->method('createEMailTemplate')
|
||||
|
|
|
@ -620,26 +620,18 @@ EOF;
|
|||
->expects($this->at(0))
|
||||
->method('setTo')
|
||||
->with(['recipient@example.com' => 'John Doe']);
|
||||
$this->defaults
|
||||
->expects($this->exactly(2))
|
||||
->method('getName')
|
||||
->willReturn('TestCloud');
|
||||
$message
|
||||
->expects($this->at(1))
|
||||
->method('setSubject')
|
||||
->with('Your TestCloud account was created');
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('setHtmlBody')
|
||||
->with($emailTemplate->renderHtml());
|
||||
$message
|
||||
->expects($this->at(3))
|
||||
->method('setPlainBody')
|
||||
->with($emailTemplate->renderText());
|
||||
$message
|
||||
->expects($this->at(4))
|
||||
->method('setFrom')
|
||||
->with(['no-reply@nextcloud.com' => 'TestCloud']);
|
||||
$message
|
||||
->expects($this->at(2))
|
||||
->method('useTemplate')
|
||||
->with($emailTemplate);
|
||||
$this->defaults
|
||||
->expects($this->exactly(1))
|
||||
->method('getName')
|
||||
->willReturn('TestCloud');
|
||||
$this->mailer
|
||||
->expects($this->once())
|
||||
->method('createMessage')
|
||||
|
|
Loading…
Reference in a new issue