Set the meta data before everything

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-09-04 14:46:05 +02:00
parent 6aa707de42
commit 54faa09b4d
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
1 changed files with 12 additions and 13 deletions

View File

@ -21,7 +21,6 @@
namespace OC\Settings\Mailer;
use OC\Mail\EMailTemplate;
use OCP\Mail\IEMailTemplate;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Defaults;
@ -96,7 +95,7 @@ class NewUserMailHelper {
/**
* @param IUser $user
* @param bool $generatePasswordResetToken
* @return EMailTemplate
* @return IEMailTemplate
*/
public function generateTemplate(IUser $user, $generatePasswordResetToken = false) {
if ($generatePasswordResetToken) {
@ -114,11 +113,19 @@ class NewUserMailHelper {
} else {
$link = $this->urlGenerator->getAbsoluteURL('/');
}
$emailTemplate = $this->mailer->createEMailTemplate();
$emailTemplate->addHeader();
$displayName = $user->getDisplayName();
$userId = $user->getUID();
$emailTemplate = $this->mailer->createEMailTemplate();
$emailTemplate->setMetaData('settings.Welcome', [
'link' => $link,
'displayname' => $displayName,
'userid' => $userId,
'instancename' => $this->themingDefaults->getName(),
'resetTokenGenerated' => $generatePasswordResetToken,
]);
$emailTemplate->addHeader();
if ($displayName === $userId) {
$emailTemplate->addHeading($this->l10n->t('Welcome aboard'));
} else {
@ -139,14 +146,6 @@ class NewUserMailHelper {
);
$emailTemplate->addFooter();
$emailTemplate->setMetaData('settings.Welcome', [
'link' => $link,
'displayname' => $displayName,
'userid' => $userId,
'instancename' => $this->themingDefaults->getName(),
'resetTokenGenerated' => $generatePasswordResetToken,
]);
return $emailTemplate;
}