#124: E-mails now send and log to the database as sent when queuing is not enabled

This commit is contained in:
Andy Heathershaw 2019-07-14 12:29:25 +01:00
parent 7418438d63
commit 216c93a750
4 changed files with 16 additions and 6 deletions

View File

@ -17,7 +17,7 @@ class QueueEmailDatabaseChannel extends EmailDatabaseWriterChannelBase
public function send($notifiable, Notification $notification) public function send($notifiable, Notification $notification)
{ {
/** @var EmailLog $logEntry */ /** @var EmailLog $logEntry */
$logEntry = $notification->toQueueEmailDatabase($notifiable); $logEntry = $notification->toEmailDatabase($notifiable);
$this->writeToTable($logEntry, true); $this->writeToTable($logEntry, true);
} }

View File

@ -6,10 +6,7 @@ use App\Facade\UserConfig;
use App\Mail\MailableBase; use App\Mail\MailableBase;
use App\Mail\ResetMyPassword; use App\Mail\ResetMyPassword;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Notifications\Notification; use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
class ResetPassword extends Notification class ResetPassword extends Notification
{ {
@ -56,7 +53,7 @@ class ResetPassword extends Notification
return $drivers; return $drivers;
} }
public function toQueueEmailDatabase($notifiable) public function toEmailDatabase($notifiable)
{ {
return $this->toMail($notifiable)->buildEmailLog(); return $this->toMail($notifiable)->buildEmailLog();
} }

View File

@ -17,7 +17,7 @@ class SentEmailDatabaseChannel extends EmailDatabaseWriterChannelBase
public function send($notifiable, Notification $notification) public function send($notifiable, Notification $notification)
{ {
/** @var EmailLog $logEntry */ /** @var EmailLog $logEntry */
$logEntry = $notification->toDatabaseWriter($notifiable); $logEntry = $notification->toEmailDatabase($notifiable);
$this->writeToTable($logEntry, false); $this->writeToTable($logEntry, false);
} }

View File

@ -0,0 +1,13 @@
[Unit]
Description=Blue Twilight E-mail Queue Runner
[Service]
WorkingDirectory=/data/www/blue-twilight.andysh.dev/
ExecStart=/usr/bin/php artisan bt-queue:send-emails --poll
Restart=on-failure
User=www-data
Group=www-data
Environment=USER=www-data HOME=/var/www
[Install]
WantedBy=multi-user.target