Merge pull request #25644 from nextcloud/fix/psalm/settings

Some psalm fixes in the settings app
This commit is contained in:
Christoph Wurst 2021-02-15 11:40:40 +01:00 committed by GitHub
commit 19666a0942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -73,7 +73,7 @@ class HelpController extends Controller {
public function help(string $mode = 'user'): TemplateResponse { public function help(string $mode = 'user'): TemplateResponse {
$this->navigationManager->setActiveEntry('help'); $this->navigationManager->setActiveEntry('help');
if (!isset($mode) || $mode !== 'admin') { if ($mode !== 'admin') {
$mode = 'user'; $mode = 'user';
} }

View File

@ -172,9 +172,16 @@ class NewUserMailHelper {
* @throws \Exception If mail could not be sent * @throws \Exception If mail could not be sent
*/ */
public function sendMail(IUser $user, public function sendMail(IUser $user,
IEMailTemplate $emailTemplate) { IEMailTemplate $emailTemplate): void {
// Be sure to never try to send to an empty e-mail
$email = $user->getEMailAddress();
if ($email === null) {
return;
}
$message = $this->mailer->createMessage(); $message = $this->mailer->createMessage();
$message->setTo([$user->getEMailAddress() => $user->getDisplayName()]); $message->setTo([$email => $user->getDisplayName()]);
$message->setFrom([$this->fromAddress => $this->themingDefaults->getName()]); $message->setFrom([$this->fromAddress => $this->themingDefaults->getName()]);
$message->useTemplate($emailTemplate); $message->useTemplate($emailTemplate);
$this->mailer->send($message); $this->mailer->send($message);