Skip to content

Commit

Permalink
Fix queue driver with emails not sending; formatting #675
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed May 8, 2020
1 parent 5367f92 commit d5fc083
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/Notifications/BaseNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function __construct()
$klass = get_class($this);
$notif_config = config('notifications.channels', []);
if (!array_key_exists($klass, $notif_config)) {
Log::error('Notification type '.$klass.' missing from notifications config');
Log::error('Notification type '.$klass.' missing from notifications config, defaulting to mail');
return;
}

Expand Down
8 changes: 5 additions & 3 deletions app/Notifications/Channels/MailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
namespace App\Notifications\Channels;

use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Support\Facades\Log;

trait MailChannel
{
private $mailSubject;
private $mailTemplate;
private $mailTemplateArgs;
protected $mailSubject;
protected $mailTemplate;
protected $mailTemplateArgs;

/**
* Set the arguments for the toMail() method
Expand All @@ -33,6 +34,7 @@ public function setMailable($subject, $template, $args)
*/
public function toMail($notifiable)
{
Log::info('Sending mail message: '.$this->mailSubject);
return (new MailMessage())
->from(config('mail.from.address', 'no-reply@phpvms.net'))
->subject($this->mailSubject)
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/AdminUserRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class AdminUserRegistered extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $user;

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/NewsAdded.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class NewsAdded extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $news;

public function __construct(News $news)
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/PirepAccepted.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class PirepAccepted extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $pirep;

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/PirepRejected.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class PirepRejected extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $pirep;

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/PirepSubmitted.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class PirepSubmitted extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $pirep;

/**
Expand Down
4 changes: 4 additions & 0 deletions app/Notifications/Messages/UserPending.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ class UserPending extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $user;

/**
* @param \App\Models\User $user
*/
public function __construct(User $user)
{
parent::__construct();

$this->user = $user;

$this->setMailable(
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/UserRegistered.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class UserRegistered extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $user;

/**
Expand Down
2 changes: 2 additions & 0 deletions app/Notifications/Messages/UserRejected.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class UserRejected extends BaseNotification
{
use MailChannel;

public $channels = ['mail'];

private $user;

/**
Expand Down
2 changes: 1 addition & 1 deletion config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
|
*/

'default' => env('QUEUE_DRIVER', 'database'),
'default' => env('QUEUE_DRIVER', 'sync'),

/*
|--------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions modules/Importer/Services/BaseImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
use App\Services\Installer\LoggerTrait;
use Carbon\Carbon;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;
use Modules\Importer\Utils\IdMapper;
use Modules\Importer\Utils\ImporterDB;

abstract class BaseImporter implements ShouldQueue
abstract class BaseImporter
{
use LoggerTrait;
use Dispatchable;
Expand Down
4 changes: 1 addition & 3 deletions resources/stubs/modules/mail.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@

namespace $NAMESPACE$;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;

/**
* Class $CLASS$
* @package $NAMESPACE$
*/
class $CLASS$ extends Mailable
{
use Queueable, SerializesModels;
use SerializesModels;

/**
* Create a new message instance.
Expand Down

0 comments on commit d5fc083

Please sign in to comment.