Emails/notifications not sending #675 (#686)

* Add test call to test notification #675

* Fix queue driver with emails not sending; formatting #675
This commit is contained in:
Nabeel S 2020-05-09 11:31:25 -04:00 committed by GitHub
parent 69fb5a537e
commit 1054d53826
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 37 additions and 10 deletions

View File

@ -7,6 +7,7 @@ use App\Models\Acars;
use App\Models\Airline; use App\Models\Airline;
use App\Models\Pirep; use App\Models\Pirep;
use App\Models\User; use App\Models\User;
use App\Notifications\Messages\UserRegistered;
use App\Repositories\AcarsRepository; use App\Repositories\AcarsRepository;
use App\Services\AirportService; use App\Services\AirportService;
use App\Services\AwardService; use App\Services\AwardService;
@ -60,6 +61,7 @@ class DevCommands extends Command
'metar' => 'getMetar', 'metar' => 'getMetar',
'recalculate-stats' => 'recalculateStats', 'recalculate-stats' => 'recalculateStats',
'reset-install' => 'resetInstall', 'reset-install' => 'resetInstall',
'new-user-email' => 'newUserEmail',
'xml-to-yaml' => 'xmlToYaml', 'xml-to-yaml' => 'xmlToYaml',
]; ];
@ -290,6 +292,16 @@ class DevCommands extends Command
$this->info('Done!'); $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 public function liveFlights(): void
{ {
$acarsRepo = app(AcarsRepository::class); $acarsRepo = app(AcarsRepository::class);

View File

@ -20,7 +20,7 @@ class BaseNotification extends Notification implements ShouldQueue
$klass = get_class($this); $klass = get_class($this);
$notif_config = config('notifications.channels', []); $notif_config = config('notifications.channels', []);
if (!array_key_exists($klass, $notif_config)) { 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; return;
} }

View File

@ -6,9 +6,9 @@ use Illuminate\Notifications\Messages\MailMessage;
trait MailChannel trait MailChannel
{ {
private $mailSubject; protected $mailSubject;
private $mailTemplate; protected $mailTemplate;
private $mailTemplateArgs; protected $mailTemplateArgs;
/** /**
* Set the arguments for the toMail() method * Set the arguments for the toMail() method

View File

@ -10,6 +10,8 @@ class AdminUserRegistered extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $user; private $user;
/** /**

View File

@ -10,6 +10,8 @@ class NewsAdded extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $news; private $news;
public function __construct(News $news) public function __construct(News $news)

View File

@ -13,6 +13,8 @@ class PirepAccepted extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $pirep; private $pirep;
/** /**

View File

@ -10,6 +10,8 @@ class PirepRejected extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $pirep; private $pirep;
/** /**

View File

@ -10,6 +10,8 @@ class PirepSubmitted extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $pirep; private $pirep;
/** /**

View File

@ -10,6 +10,8 @@ class UserPending extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $user; private $user;
/** /**
@ -17,6 +19,8 @@ class UserPending extends BaseNotification
*/ */
public function __construct(User $user) public function __construct(User $user)
{ {
parent::__construct();
$this->user = $user; $this->user = $user;
$this->setMailable( $this->setMailable(

View File

@ -10,6 +10,8 @@ class UserRegistered extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $user; private $user;
/** /**

View File

@ -10,6 +10,8 @@ class UserRejected extends BaseNotification
{ {
use MailChannel; use MailChannel;
public $channels = ['mail'];
private $user; private $user;
/** /**

View File

@ -14,7 +14,7 @@ return [
| |
*/ */
'default' => env('QUEUE_DRIVER', 'database'), 'default' => env('QUEUE_DRIVER', 'sync'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -5,14 +5,13 @@ namespace Modules\Importer\Services;
use App\Services\Installer\LoggerTrait; use App\Services\Installer\LoggerTrait;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Modules\Importer\Utils\IdMapper; use Modules\Importer\Utils\IdMapper;
use Modules\Importer\Utils\ImporterDB; use Modules\Importer\Utils\ImporterDB;
abstract class BaseImporter implements ShouldQueue abstract class BaseImporter
{ {
use LoggerTrait; use LoggerTrait;
use Dispatchable; use Dispatchable;

View File

@ -2,10 +2,8 @@
namespace $NAMESPACE$; namespace $NAMESPACE$;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable; use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
/** /**
* Class $CLASS$ * Class $CLASS$
@ -13,7 +11,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
*/ */
class $CLASS$ extends Mailable class $CLASS$ extends Mailable
{ {
use Queueable, SerializesModels; use SerializesModels;
/** /**
* Create a new message instance. * Create a new message instance.