Skip to content

Commit

Permalink
Emails/notifications not sending #675 (#686)
Browse files Browse the repository at this point in the history
* Add test call to test notification #675

* Fix queue driver with emails not sending; formatting #675
  • Loading branch information
nabeelio committed May 9, 2020
1 parent 69fb5a5 commit 1054d53
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 10 deletions.
12 changes: 12 additions & 0 deletions app/Console/Commands/DevCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Airline;
use App\Models\Pirep;
use App\Models\User;
use App\Notifications\Messages\UserRegistered;
use App\Repositories\AcarsRepository;
use App\Services\AirportService;
use App\Services\AwardService;
Expand Down Expand Up @@ -60,6 +61,7 @@ public function handle()
'metar' => 'getMetar',
'recalculate-stats' => 'recalculateStats',
'reset-install' => 'resetInstall',
'new-user-email' => 'newUserEmail',
'xml-to-yaml' => 'xmlToYaml',
];

Expand Down Expand Up @@ -290,6 +292,16 @@ protected function resetInstall(): void
$this->info('Done!');
}

/**
* Test sending a user a registered email
*/
protected function newUserEmail()
{
$user_id = $this->argument('param');
$user = User::find($user_id);
$user->notify(new UserRegistered($user));
}

public function liveFlights(): void
{
$acarsRepo = app(AcarsRepository::class);
Expand Down
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
6 changes: 3 additions & 3 deletions app/Notifications/Channels/MailChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

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

/**
* Set the arguments for the toMail() method
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 1054d53

Please sign in to comment.