mirror of
https://github.com/flarum/core.git
synced 2025-08-04 15:37:51 +02:00
Send emails through the queue
This commit is contained in:
committed by
Daniël Klabbers
parent
857fd95b5e
commit
03a4997a1c
@@ -10,12 +10,12 @@
|
||||
namespace Flarum\Api\Controller;
|
||||
|
||||
use Flarum\Http\UrlGenerator;
|
||||
use Flarum\Mail\Job\SendRawEmailJob;
|
||||
use Flarum\Settings\SettingsRepositoryInterface;
|
||||
use Flarum\User\AssertPermissionTrait;
|
||||
use Flarum\User\EmailToken;
|
||||
use Flarum\User\Exception\PermissionDeniedException;
|
||||
use Illuminate\Contracts\Mail\Mailer;
|
||||
use Illuminate\Mail\Message;
|
||||
use Illuminate\Contracts\Queue\Queue;
|
||||
use Illuminate\Support\Arr;
|
||||
use Laminas\Diactoros\Response\EmptyResponse;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
@@ -33,9 +33,9 @@ class SendConfirmationEmailController implements RequestHandlerInterface
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* @var Mailer
|
||||
* @var Queue
|
||||
*/
|
||||
protected $mailer;
|
||||
protected $queue;
|
||||
|
||||
/**
|
||||
* @var UrlGenerator
|
||||
@@ -49,14 +49,14 @@ class SendConfirmationEmailController implements RequestHandlerInterface
|
||||
|
||||
/**
|
||||
* @param \Flarum\Settings\SettingsRepositoryInterface $settings
|
||||
* @param Mailer $mailer
|
||||
* @param Queue $queue
|
||||
* @param UrlGenerator $url
|
||||
* @param TranslatorInterface $translator
|
||||
*/
|
||||
public function __construct(SettingsRepositoryInterface $settings, Mailer $mailer, UrlGenerator $url, TranslatorInterface $translator)
|
||||
public function __construct(SettingsRepositoryInterface $settings, Queue $queue, UrlGenerator $url, TranslatorInterface $translator)
|
||||
{
|
||||
$this->settings = $settings;
|
||||
$this->mailer = $mailer;
|
||||
$this->queue = $queue;
|
||||
$this->url = $url;
|
||||
$this->translator = $translator;
|
||||
}
|
||||
@@ -85,11 +85,9 @@ class SendConfirmationEmailController implements RequestHandlerInterface
|
||||
];
|
||||
|
||||
$body = $this->translator->trans('core.email.activate_account.body', $data);
|
||||
$subject = $this->translator->trans('core.email.activate_account.subject');
|
||||
|
||||
$this->mailer->raw($body, function (Message $message) use ($actor) {
|
||||
$message->to($actor->email);
|
||||
$message->subject($this->translator->trans('core.email.activate_account.subject'));
|
||||
});
|
||||
$this->queue->push(new SendRawEmailJob($actor->email, $subject, $body));
|
||||
|
||||
return new EmptyResponse;
|
||||
}
|
||||
|
Reference in New Issue
Block a user