Refactor emails

This commit is contained in:
David Bomba 2021-02-15 16:08:05 +11:00
parent 5076b8c70c
commit e4697bb5f3
2 changed files with 15 additions and 1 deletions

View File

@ -12,7 +12,11 @@
namespace App\Listeners\Credit;
use App\Jobs\Mail\EntitySentMailer;
use App\Jobs\Mail\NinjaMailer;
use App\Jobs\Mail\NinjaMailerJob;
use App\Jobs\Mail\NinjaMailerObject;
use App\Libraries\MultiDB;
use App\Mail\Admin\EntitySentObject;
use App\Notifications\Admin\EntitySentNotification;
use App\Utils\Traits\Notifications\UserNotifies;
use Illuminate\Contracts\Queue\ShouldQueue;
@ -41,6 +45,11 @@ class CreditEmailedNotification implements ShouldQueue
$credit->last_sent_date = now();
$credit->save();
$nmo = new NinjaMailerObject;
$nmo->mailable = new NinjaMailer( (new EntitySentObject($event->invitation, 'credit', $event->template))->build() );
$nmo->company = $credit->company;
$nmo->settings = $credit->company->settings;
foreach ($event->invitation->company->company_users as $company_user) {
$user = $company_user->user;
@ -51,7 +60,11 @@ class CreditEmailedNotification implements ShouldQueue
if (($key = array_search('mail', $methods)) !== false && $first_notification_sent === true) {
unset($methods[$key]);
EntitySentMailer::dispatch($event->invitation, 'credit', $user, $event->invitation->company, $event->template);
$nmo->to_user = $user;
NinjaMailerJob::dispatch($nmo);
//EntitySentMailer::dispatch($event->invitation, 'credit', $user, $event->invitation->company, $event->template);
$first_notification_sent = false;
}

View File

@ -21,6 +21,7 @@ use Illuminate\Notifications\Notification;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
//@deprecated
class EntitySentNotification extends Notification implements ShouldQueue
{
//use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;