Skip to content

Commit

Permalink
make displayname available to informational emails
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Aug 21, 2023
1 parent c281005 commit 989624a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 6 deletions.
8 changes: 5 additions & 3 deletions framework/core/src/Mail/Job/SendInformationalEmailJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ class SendInformationalEmailJob extends AbstractJob
{
public function __construct(
private readonly string $email,
private readonly string $displayName,
private readonly string $subject,
private readonly string $body,
private readonly string $forumTitle,
private readonly ?string $bodyTitle = null,
protected array $views = [
'plain' => 'flarum.forum::email.information.plain.base',
'html' => 'flarum.forum::email.information.html.base'
'plain' => 'flarum.forum::email.plain.information.base',
'html' => 'flarum.forum::email.html.information.base'
]
) {
}
Expand All @@ -34,10 +35,11 @@ public function handle(Mailer $mailer): void
$infoContent = $this->body;
$userEmail = $this->email;
$title = $this->bodyTitle;
$username = $this->displayName;

$mailer->send(
$this->views,
compact('forumTitle', 'infoContent', 'userEmail', 'title'),
compact('forumTitle', 'infoContent', 'userEmail', 'title', 'username'),
function (Message $message) {
$message->to($this->email);
$message->subject($this->subject);
Expand Down
2 changes: 1 addition & 1 deletion framework/core/src/User/AccountActivationMailerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ protected function sendConfirmationEmail(User $user, array $data): void
$body = $this->translator->trans('core.email.activate_account.body', $data);
$subject = $this->translator->trans('core.email.activate_account.subject');

$this->queue->push(new SendInformationalEmailJob($user->email, $subject, $body, Arr::get($data, 'forum')));
$this->queue->push(new SendInformationalEmailJob(email: $user->email, subject: $subject, body: $body, forumTitle: Arr::get($data, 'forum'), displayName: Arr::get($data, 'username')));
}
}
2 changes: 1 addition & 1 deletion framework/core/src/User/EmailConfirmationMailer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function handle(EmailChangeRequested $event): void
$body = $this->translator->trans('core.email.confirm_email.body', $data);
$subject = $this->translator->trans('core.email.confirm_email.subject');

$this->queue->push(new SendInformationalEmailJob($email, $subject, $body, Arr::get($data, 'forum')));
$this->queue->push(new SendInformationalEmailJob(email: $email, subject:$subject, body: $body, forumTitle: Arr::get($data, 'forum'), displayName: Arr::get($data, 'username')));
}

protected function generateToken(User $user, string $email): EmailToken
Expand Down
9 changes: 8 additions & 1 deletion framework/core/src/User/Job/RequestPasswordResetJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ public function handle(
$body = $translator->trans('core.email.reset_password.body', $data);
$subject = $translator->trans('core.email.reset_password.subject');

$queue->push(new SendInformationalEmailJob($user->email, $subject, $body, Arr::get($data, 'forum')));
$queue->push(new SendInformationalEmailJob(
email: $user->email,
subject: $subject,
body: $body,
forumTitle: Arr::get($data, 'forum'),
displayName: Arr::get($data, 'username'),
bodyTitle: $subject
));
}
}

0 comments on commit 989624a

Please sign in to comment.