Adding user email address in admin notification email

Signed-off-by: Samuel Degoul <samuel.degoul@posteo.net>
This commit is contained in:
Samuel Degoul 2021-08-13 11:17:05 +02:00
parent f55083c8d4
commit 36515085db
No known key found for this signature in database
GPG Key ID: EB5FE2B48557243C
2 changed files with 8 additions and 6 deletions

View File

@ -147,7 +147,7 @@ class MailService {
} }
} }
public function notifyAdmins(string $userId, bool $userIsEnabled, string $userGroupId): void { public function notifyAdmins(string $userId, string $userEMailAddress, bool $userIsEnabled, string $userGroupId): void {
// Notify admin // Notify admin
$adminUsers = $this->groupManager->get('admin')->getUsers(); $adminUsers = $this->groupManager->get('admin')->getUsers();
@ -172,7 +172,7 @@ class MailService {
} }
try { try {
$this->sendNewUserNotifyEmail($toArr, $userId, $userIsEnabled); $this->sendNewUserNotifyEmail($toArr, $userId, $userEMailAddress, $userIsEnabled);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->logger->error('Sending admin notification email failed: '. $e->getMessage()); $this->logger->error('Sending admin notification email failed: '. $e->getMessage());
} }
@ -186,7 +186,7 @@ class MailService {
* @param bool $userIsEnabled the new user account is enabled * @param bool $userIsEnabled the new user account is enabled
* @throws \Exception * @throws \Exception
*/ */
private function sendNewUserNotifyEmail(array $to, string $username, bool $userIsEnabled): void { private function sendNewUserNotifyEmail(array $to, string $username, string $userEMailAddress, bool $userIsEnabled): void {
$link = $this->urlGenerator->linkToRouteAbsolute('settings.Users.usersListByGroup', [ $link = $this->urlGenerator->linkToRouteAbsolute('settings.Users.usersListByGroup', [
'group' => 'disabled', 'group' => 'disabled',
]); ]);
@ -204,15 +204,17 @@ class MailService {
if ($userIsEnabled) { if ($userIsEnabled) {
$template->addBodyText( $template->addBodyText(
$this->l10n->t('"%1$s" registered a new account on %2$s.', [ $this->l10n->t('"%1$s" (%2$s) registered a new account on %3$s.', [
$username, $username,
$userEMailAddress,
$this->defaults->getName(), $this->defaults->getName(),
]) ])
); );
} else { } else {
$template->addBodyText( $template->addBodyText(
$this->l10n->t('"%1$s" registered a new account on %2$s and needs to be enabled.', [ $this->l10n->t('"%1$s" (%2$s) registered a new account on %3$s and needs to be enabled.', [
$username, $username,
$userEMailAddress,
$this->defaults->getName(), $this->defaults->getName(),
]) ])
); );

View File

@ -427,7 +427,7 @@ class RegistrationService {
$user->setEnabled(false); $user->setEnabled(false);
} }
$this->mailService->notifyAdmins($userId, $user->isEnabled(), $groupId); $this->mailService->notifyAdmins($userId, $user->getEMailAddress(), $user->isEnabled(), $groupId);
return $user; return $user;
} }