diff --git a/app/Console/Commands/DevCommands.php b/app/Console/Commands/DevCommands.php index 836f2324..dc5cfe2f 100644 --- a/app/Console/Commands/DevCommands.php +++ b/app/Console/Commands/DevCommands.php @@ -7,6 +7,7 @@ use App\Models\Acars; 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; @@ -60,6 +61,7 @@ class DevCommands extends Command 'metar' => 'getMetar', 'recalculate-stats' => 'recalculateStats', 'reset-install' => 'resetInstall', + 'new-user-email' => 'newUserEmail', 'xml-to-yaml' => 'xmlToYaml', ]; @@ -290,6 +292,16 @@ class DevCommands extends Command $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); diff --git a/app/Notifications/BaseNotification.php b/app/Notifications/BaseNotification.php index 3b68b31c..234ef5c8 100644 --- a/app/Notifications/BaseNotification.php +++ b/app/Notifications/BaseNotification.php @@ -20,7 +20,7 @@ class BaseNotification extends Notification implements ShouldQueue $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; } diff --git a/app/Notifications/Channels/MailChannel.php b/app/Notifications/Channels/MailChannel.php index 3cb150b0..0112882d 100644 --- a/app/Notifications/Channels/MailChannel.php +++ b/app/Notifications/Channels/MailChannel.php @@ -6,9 +6,9 @@ use Illuminate\Notifications\Messages\MailMessage; trait MailChannel { - private $mailSubject; - private $mailTemplate; - private $mailTemplateArgs; + protected $mailSubject; + protected $mailTemplate; + protected $mailTemplateArgs; /** * Set the arguments for the toMail() method diff --git a/app/Notifications/Messages/AdminUserRegistered.php b/app/Notifications/Messages/AdminUserRegistered.php index a007641b..9ddbcd2b 100644 --- a/app/Notifications/Messages/AdminUserRegistered.php +++ b/app/Notifications/Messages/AdminUserRegistered.php @@ -10,6 +10,8 @@ class AdminUserRegistered extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $user; /** diff --git a/app/Notifications/Messages/NewsAdded.php b/app/Notifications/Messages/NewsAdded.php index 38ae343d..3032cab2 100644 --- a/app/Notifications/Messages/NewsAdded.php +++ b/app/Notifications/Messages/NewsAdded.php @@ -10,6 +10,8 @@ class NewsAdded extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $news; public function __construct(News $news) diff --git a/app/Notifications/Messages/PirepAccepted.php b/app/Notifications/Messages/PirepAccepted.php index 70979621..a4b702ec 100644 --- a/app/Notifications/Messages/PirepAccepted.php +++ b/app/Notifications/Messages/PirepAccepted.php @@ -13,6 +13,8 @@ class PirepAccepted extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $pirep; /** diff --git a/app/Notifications/Messages/PirepRejected.php b/app/Notifications/Messages/PirepRejected.php index 6c5ade9b..c28f63da 100644 --- a/app/Notifications/Messages/PirepRejected.php +++ b/app/Notifications/Messages/PirepRejected.php @@ -10,6 +10,8 @@ class PirepRejected extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $pirep; /** diff --git a/app/Notifications/Messages/PirepSubmitted.php b/app/Notifications/Messages/PirepSubmitted.php index bcceedff..40500250 100644 --- a/app/Notifications/Messages/PirepSubmitted.php +++ b/app/Notifications/Messages/PirepSubmitted.php @@ -10,6 +10,8 @@ class PirepSubmitted extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $pirep; /** diff --git a/app/Notifications/Messages/UserPending.php b/app/Notifications/Messages/UserPending.php index 000eb393..f737ea47 100644 --- a/app/Notifications/Messages/UserPending.php +++ b/app/Notifications/Messages/UserPending.php @@ -10,6 +10,8 @@ class UserPending extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $user; /** @@ -17,6 +19,8 @@ class UserPending extends BaseNotification */ public function __construct(User $user) { + parent::__construct(); + $this->user = $user; $this->setMailable( diff --git a/app/Notifications/Messages/UserRegistered.php b/app/Notifications/Messages/UserRegistered.php index 0c766a44..894a03da 100644 --- a/app/Notifications/Messages/UserRegistered.php +++ b/app/Notifications/Messages/UserRegistered.php @@ -10,6 +10,8 @@ class UserRegistered extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $user; /** diff --git a/app/Notifications/Messages/UserRejected.php b/app/Notifications/Messages/UserRejected.php index 8c4b8079..03d64efd 100644 --- a/app/Notifications/Messages/UserRejected.php +++ b/app/Notifications/Messages/UserRejected.php @@ -10,6 +10,8 @@ class UserRejected extends BaseNotification { use MailChannel; + public $channels = ['mail']; + private $user; /** diff --git a/config/queue.php b/config/queue.php index e6031055..e4026e0d 100755 --- a/config/queue.php +++ b/config/queue.php @@ -14,7 +14,7 @@ return [ | */ - 'default' => env('QUEUE_DRIVER', 'database'), + 'default' => env('QUEUE_DRIVER', 'sync'), /* |-------------------------------------------------------------------------- diff --git a/modules/Importer/Services/BaseImporter.php b/modules/Importer/Services/BaseImporter.php index eace47c5..67938181 100644 --- a/modules/Importer/Services/BaseImporter.php +++ b/modules/Importer/Services/BaseImporter.php @@ -5,14 +5,13 @@ namespace Modules\Importer\Services; 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; diff --git a/resources/stubs/modules/mail.stub b/resources/stubs/modules/mail.stub index aa3f514f..bcb7fc4d 100644 --- a/resources/stubs/modules/mail.stub +++ b/resources/stubs/modules/mail.stub @@ -2,10 +2,8 @@ namespace $NAMESPACE$; -use Illuminate\Bus\Queueable; use Illuminate\Mail\Mailable; use Illuminate\Queue\SerializesModels; -use Illuminate\Contracts\Queue\ShouldQueue; /** * Class $CLASS$ @@ -13,7 +11,7 @@ use Illuminate\Contracts\Queue\ShouldQueue; */ class $CLASS$ extends Mailable { - use Queueable, SerializesModels; + use SerializesModels; /** * Create a new message instance.