summaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/lib/Controller
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-04-07 14:52:28 -0500
committerGitHub <noreply@github.com>2017-04-07 14:52:28 -0500
commit8838ed4c2ea50e9205dd7b106bf6aeda9e0a1171 (patch)
treefa652016000acb8df5838a7d3e0049e7079ecb9f /apps/provisioning_api/lib/Controller
parent4c60360bf733fab8882939f2cd9dca57b6fe405e (diff)
parent8daf3d4a70bc97b6680956f6b13143e184a83c96 (diff)
downloadnextcloud-server-8838ed4c2ea50e9205dd7b106bf6aeda9e0a1171.tar.gz
nextcloud-server-8838ed4c2ea50e9205dd7b106bf6aeda9e0a1171.zip
Merge pull request #4244 from nextcloud/welcome-email
New layout for welcome email
Diffstat (limited to 'apps/provisioning_api/lib/Controller')
-rw-r--r--apps/provisioning_api/lib/Controller/UsersController.php34
1 files changed, 10 insertions, 24 deletions
diff --git a/apps/provisioning_api/lib/Controller/UsersController.php b/apps/provisioning_api/lib/Controller/UsersController.php
index cb4e4b32917..9684c7f5656 100644
--- a/apps/provisioning_api/lib/Controller/UsersController.php
+++ b/apps/provisioning_api/lib/Controller/UsersController.php
@@ -30,6 +30,7 @@
namespace OCA\Provisioning_API\Controller;
use OC\Accounts\AccountManager;
+use OC\Settings\Mailer\NewUserMailHelper;
use \OC_Helper;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\TemplateResponse;
@@ -72,6 +73,8 @@ class UsersController extends OCSController {
private $defaults;
/** @var IFactory */
private $l10nFactory;
+ /** @var NewUserMailHelper */
+ private $newUserMailHelper;
/**
* @param string $appName
@@ -87,6 +90,7 @@ class UsersController extends OCSController {
* @param IMailer $mailer
* @param \OC_Defaults $defaults
* @param IFactory $l10nFactory
+ * @param NewUserMailHelper $newUserMailHelper
*/
public function __construct($appName,
IRequest $request,
@@ -100,7 +104,8 @@ class UsersController extends OCSController {
IURLGenerator $urlGenerator,
IMailer $mailer,
\OC_Defaults $defaults,
- IFactory $l10nFactory) {
+ IFactory $l10nFactory,
+ NewUserMailHelper $newUserMailHelper) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
@@ -114,6 +119,7 @@ class UsersController extends OCSController {
$this->mailer = $mailer;
$this->defaults = $defaults;
$this->l10nFactory = $l10nFactory;
+ $this->newUserMailHelper = $newUserMailHelper;
}
/**
@@ -807,30 +813,10 @@ class UsersController extends OCSController {
$l10n = $this->l10nFactory->get('settings', $lang);
- // data for the mail template
- $mailData = [
- 'username' => $username,
- 'url' => $this->urlGenerator->getAbsoluteURL('/')
- ];
-
- // FIXME: set users language in email
- $mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
- $mailContent = $mail->render();
-
- // FIXME: set users language in email
- $mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
- $plainTextMailContent = $mail->render();
-
- $subject = $l10n->t('Your %s account was created', [$this->defaults->getName()]);
-
try {
- $message = $this->mailer->createMessage();
- $message->setTo([$email => $username]);
- $message->setSubject($subject);
- $message->setHtmlBody($mailContent);
- $message->setPlainBody($plainTextMailContent);
- $message->setFrom([$this->fromMailAddress => $this->defaults->getName()]);
- $this->mailer->send($message);
+ $this->newUserMailHelper->setL10N($l10n);
+ $emailTemplate = $this->newUserMailHelper->generateTemplate($targetUser, false);
+ $this->newUserMailHelper->sendMail($targetUser, $emailTemplate);
} catch(\Exception $e) {
$this->logger->error("Can't send new user mail to $email: " . $e->getMessage(), array('app' => 'settings'));
throw new OCSException('Sending email failed', 102);