summaryrefslogtreecommitdiffstats
path: root/lib/private/Mail
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-03-31 14:02:39 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2020-04-16 09:04:13 +0200
commitbb4dedb0156727ebd88a3f922fedc78436d7b701 (patch)
treee1975ad11d4d3903c6c1520f93a1a398f80ac1b6 /lib/private/Mail
parent078ac97939747eec246ed105830d4643b81d994c (diff)
downloadnextcloud-server-bb4dedb0156727ebd88a3f922fedc78436d7b701.tar.gz
nextcloud-server-bb4dedb0156727ebd88a3f922fedc78436d7b701.zip
Provide the proper language to the mailer
Else we can't properly translate the footer in the recipients e-mail language. Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Mail')
-rw-r--r--lib/private/Mail/EMailTemplate.php22
-rw-r--r--lib/private/Mail/Mailer.php9
2 files changed, 15 insertions, 16 deletions
diff --git a/lib/private/Mail/EMailTemplate.php b/lib/private/Mail/EMailTemplate.php
index 9e2f099259c..3bb5b299f4e 100644
--- a/lib/private/Mail/EMailTemplate.php
+++ b/lib/private/Mail/EMailTemplate.php
@@ -35,8 +35,8 @@ declare(strict_types=1);
namespace OC\Mail;
use OCP\Defaults;
-use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use OCP\Mail\IEMailTemplate;
/**
@@ -52,8 +52,8 @@ class EMailTemplate implements IEMailTemplate {
protected $themingDefaults;
/** @var IURLGenerator */
protected $urlGenerator;
- /** @var IL10N */
- protected $l10n;
+ /** @var IFactory */
+ protected $l10nFactory;
/** @var string */
protected $emailId;
/** @var array */
@@ -350,21 +350,14 @@ EOF;
</table>
EOF;
- /**
- * @param Defaults $themingDefaults
- * @param IURLGenerator $urlGenerator
- * @param IL10N $l10n
- * @param string $emailId
- * @param array $data
- */
public function __construct(Defaults $themingDefaults,
IURLGenerator $urlGenerator,
- IL10N $l10n,
+ IFactory $l10nFactory,
$emailId,
array $data) {
$this->themingDefaults = $themingDefaults;
$this->urlGenerator = $urlGenerator;
- $this->l10n = $l10n;
+ $this->l10nFactory = $l10nFactory;
$this->htmlBody .= $this->head;
$this->emailId = $emailId;
$this->data = $data;
@@ -605,9 +598,10 @@ EOF;
*
* @param string $text If the text is empty the default "Name - Slogan<br>This is an automatically sent email" will be used
*/
- public function addFooter(string $text = '') {
+ public function addFooter(string $text = '', ?string $lang = null) {
if ($text === '') {
- $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan() . '<br>' . $this->l10n->t('This is an automatically sent email, please do not reply.');
+ $l10n = $this->l10nFactory->get('lib', $lang);
+ $text = $this->themingDefaults->getName() . ' - ' . $this->themingDefaults->getSlogan($lang) . '<br>' . $l10n->t('This is an automatically sent email, please do not reply.');
}
if ($this->footerAdded) {
diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php
index 57778e263d7..3ef77e6239c 100644
--- a/lib/private/Mail/Mailer.php
+++ b/lib/private/Mail/Mailer.php
@@ -41,6 +41,7 @@ use OCP\IConfig;
use OCP\IL10N;
use OCP\ILogger;
use OCP\IURLGenerator;
+use OCP\L10N\IFactory;
use OCP\Mail\IAttachment;
use OCP\Mail\IEMailTemplate;
use OCP\Mail\IMailer;
@@ -80,6 +81,8 @@ class Mailer implements IMailer {
private $l10n;
/** @var IEventDispatcher */
private $dispatcher;
+ /** @var IFactory */
+ private $l10nFactory;
/**
* @param IConfig $config
@@ -94,13 +97,15 @@ class Mailer implements IMailer {
Defaults $defaults,
IURLGenerator $urlGenerator,
IL10N $l10n,
- IEventDispatcher $dispatcher) {
+ IEventDispatcher $dispatcher,
+ IFactory $l10nFactory) {
$this->config = $config;
$this->logger = $logger;
$this->defaults = $defaults;
$this->urlGenerator = $urlGenerator;
$this->l10n = $l10n;
$this->dispatcher = $dispatcher;
+ $this->l10nFactory = $l10nFactory;
}
/**
@@ -158,7 +163,7 @@ class Mailer implements IMailer {
return new EMailTemplate(
$this->defaults,
$this->urlGenerator,
- $this->l10n,
+ $this->l10nFactory,
$emailId,
$data
);