From a566d8b0a2ea83639c0b8c3b76be559fb8c3827a Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 28 Oct 2022 14:37:01 +1100 Subject: [PATCH] Fixes for breaking change in CreateInvoicePdf --- app/Jobs/Mail/NinjaMailerJob.php | 9 +++++---- app/Jobs/Ninja/AdjustEmailQuota.php | 11 +++++++++-- app/Jobs/Ninja/QueueSize.php | 2 +- app/Jobs/PostMark/ProcessPostmarkWebhook.php | 12 ++++++------ app/Jobs/RecurringInvoice/SendRecurring.php | 2 +- app/Listeners/Invoice/CreateInvoicePdf.php | 4 ++-- 6 files changed, 24 insertions(+), 16 deletions(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index 1b6d50cd902c..b30723a1ff62 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -122,12 +122,13 @@ class NinjaMailerJob implements ShouldQueue ->to($this->nmo->to_user->email) ->send($this->nmo->mailable); - LightLogs::create(new EmailSuccess($this->nmo->company->company_key)) - ->batch(); - /* Count the amount of emails sent across all the users accounts */ Cache::increment($this->company->account->key); + LightLogs::create(new EmailSuccess($this->nmo->company->company_key)) + ->send(); + + } catch (\Exception | \RuntimeException | \Google\Service\Exception $e) { nlog("error failed with {$e->getMessage()}"); @@ -394,7 +395,7 @@ class NinjaMailerJob implements ShouldQueue $job_failure->string_metric6 = substr($errors, 0, 150); LightLogs::create($job_failure) - ->queue(); + ->send(); } public function failed($exception = null) diff --git a/app/Jobs/Ninja/AdjustEmailQuota.php b/app/Jobs/Ninja/AdjustEmailQuota.php index 0df03eb60c49..a90432602e6b 100644 --- a/app/Jobs/Ninja/AdjustEmailQuota.php +++ b/app/Jobs/Ninja/AdjustEmailQuota.php @@ -63,8 +63,15 @@ class AdjustEmailQuota implements ShouldQueue $email_count = Cache::get($account->key); - if($email_count > 0) - LightLogs::create(new EmailCount($email_count, $account->key))->batch(); + if($email_count > 0){ + + try{ + LightLogs::create(new EmailCount($email_count, $account->key))->send(); + } + catch(\Exception $e){ + nlog($e->getMessage()); + } + } Cache::forget($account->key); Cache::forget("throttle_notified:{$account->key}"); diff --git a/app/Jobs/Ninja/QueueSize.php b/app/Jobs/Ninja/QueueSize.php index 6b037344f401..3503f5312438 100644 --- a/app/Jobs/Ninja/QueueSize.php +++ b/app/Jobs/Ninja/QueueSize.php @@ -43,6 +43,6 @@ class QueueSize implements ShouldQueue public function handle() { LightLogs::create(new QueueSizeAnalytic(Queue::size())) - ->queue(); + ->send(); } } diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index 2f79eb177478..5567d9536103 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -142,7 +142,7 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->invitation->opened_date = now(); $this->invitation->save(); - SystemLogger::dispatch($this->request, + SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_OPENED, SystemLog::TYPE_WEBHOOK_RESPONSE, @@ -171,7 +171,7 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->invitation->email_status = 'delivered'; $this->invitation->save(); - SystemLogger::dispatch($this->request, + SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_DELIVERY, SystemLog::TYPE_WEBHOOK_RESPONSE, @@ -217,9 +217,9 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->request['MessageID'] ); - LightLogs::create($bounce)->batch(); + LightLogs::create($bounce)->send(); - SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); + SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); // if(config('ninja.notification.slack')) // $this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja(); @@ -263,9 +263,9 @@ class ProcessPostmarkWebhook implements ShouldQueue $this->request['MessageID'] ); - LightLogs::create($spam)->batch(); + LightLogs::create($spam)->send(); - SystemLogger::dispatch($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); + SystemLogger::dispatchSync($this->request, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_SPAM_COMPLAINT, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company); if(config('ninja.notification.slack')) $this->invitation->company->notification(new EmailSpamNotification($this->invitation->company->account))->ninja(); diff --git a/app/Jobs/RecurringInvoice/SendRecurring.php b/app/Jobs/RecurringInvoice/SendRecurring.php index 41f0cfa864d6..af12aeba7732 100644 --- a/app/Jobs/RecurringInvoice/SendRecurring.php +++ b/app/Jobs/RecurringInvoice/SendRecurring.php @@ -181,7 +181,7 @@ class SendRecurring implements ShouldQueue $job_failure->string_metric6 = $exception->getMessage(); LightLogs::create($job_failure) - ->queue(); + ->send(); nlog(print_r($exception->getMessage(), 1)); } diff --git a/app/Listeners/Invoice/CreateInvoicePdf.php b/app/Listeners/Invoice/CreateInvoicePdf.php index dcbf646a5708..0298a149ff7f 100644 --- a/app/Listeners/Invoice/CreateInvoicePdf.php +++ b/app/Listeners/Invoice/CreateInvoicePdf.php @@ -46,14 +46,14 @@ class CreateInvoicePdf implements ShouldQueue if (isset($event->quote)) { $event->quote->invitations->each(function ($invitation) { // CreateEntityPdf::dispatch($invitation->load('quote', 'contact.client.company')); - (new CreateEntityPdf($invitation->load('invoice', 'contact.client.company')))->handle(); + (new CreateEntityPdf($invitation->load('quote', 'contact.client.company')))->handle(); }); } if (isset($event->credit)) { $event->credit->invitations->each(function ($invitation) { // CreateEntityPdf::dispatch($invitation->load('credit', 'contact.client.company')); - (new CreateEntityPdf($invitation->load('invoice', 'contact.client.company')))->handle(); + (new CreateEntityPdf($invitation->load('credit', 'contact.client.company')))->handle(); }); }