diff --git a/lib/Controller/UserController.php b/lib/Controller/UserController.php index 96bf75a37539c26557bb82a72b046240ac03cfd9..1d0745d6cb3f1468c2a00bb73a6aff4e01a8d2f0 100644 --- a/lib/Controller/UserController.php +++ b/lib/Controller/UserController.php @@ -12,6 +12,7 @@ use OCP\AppFramework\Http\DataResponse; use OCP\IConfig; use OCP\ILogger; use OCP\IRequest; +use OCP\L10N\IFactory; class UserController extends ApiController { /** @var UserService */ @@ -22,13 +23,14 @@ class UserController extends ApiController { private $logger; private $config; - - public function __construct($appName, IRequest $request, ILogger $logger, IConfig $config, UserService $userService, MailUsageMapper $mailUsageMapper) { + protected $l10nFactory; + public function __construct($appName, IRequest $request, ILogger $logger, IConfig $config, UserService $userService, MailUsageMapper $mailUsageMapper, IFactory $l10nFactory) { parent::__construct($appName, $request); $this->userService = $userService; $this->mailUsageMapper = $mailUsageMapper; $this->logger = $logger; $this->config = $config; + $this->l10nFactory = $l10nFactory; } /** @@ -65,7 +67,7 @@ class UserController extends ApiController { * @PublicPage * @NoCSRFRequired */ - public function setAccountData(string $token, string $uid, string $email, string $recoveryEmail, string $hmeAlias, string $quota = '1024 MB', bool $tosAccepted = false): DataResponse { + public function setAccountData(string $token, string $uid, string $email, string $recoveryEmail, string $hmeAlias, string $quota = '1024 MB', bool $tosAccepted = false, string $userLanguage = 'en'): DataResponse { $response = new DataResponse(); if (!$this->checkAppCredentials($token)) { @@ -87,7 +89,10 @@ class UserController extends ApiController { $user->setEMailAddress($email); $user->setQuota($quota); - $this->userService->sendWelcomeEmail($uid, $email); + if ($this->l10nFactory->languageExists(null, $userLanguage)) { + $this->config->setUserValue($uid, 'core', 'lang', $userLanguage); + } + // $this->userService->sendWelcomeEmail($uid, $email); $this->config->setUserValue($uid, 'terms_of_service', 'tosAccepted', intval($tosAccepted)); $recoveryEmailUpdated = $this->userService->setRecoveryEmail($uid, $recoveryEmail); if (!$recoveryEmailUpdated) {