From 52c0bcbc186d06b61eae11bb68a27f6afb0c18c3 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 7 Jul 2021 18:43:34 +1000 Subject: [PATCH] Inject small delay when sending emails --- app/Http/Controllers/InvoiceController.php | 2 +- app/Jobs/Entity/CreateEntityPdf.php | 12 +----------- app/Mail/Engine/InvoiceEmailEngine.php | 2 -- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index f73b93eb465f..80c00fe4e906 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -725,7 +725,7 @@ class InvoiceController extends BaseController $invoice->service()->touchReminder($this->reminder_template)->deletePdf()->save(); $invoice->invitations->load('contact.client.country', 'invoice.client.country', 'invoice.company')->each(function ($invitation) use ($invoice) { - EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template); + EmailEntity::dispatch($invitation, $invoice->company, $this->reminder_template)->delay(now()->addSeconds(30)); }); if ($invoice->invitations->count() >= 1) { diff --git a/app/Jobs/Entity/CreateEntityPdf.php b/app/Jobs/Entity/CreateEntityPdf.php index 8ab5538426e3..29fae7e9d9ed 100644 --- a/app/Jobs/Entity/CreateEntityPdf.php +++ b/app/Jobs/Entity/CreateEntityPdf.php @@ -201,18 +201,8 @@ class CreateEntityPdf implements ShouldQueue if(!Storage::disk($this->disk)->exists($path)) Storage::disk($this->disk)->makeDirectory($path, 0775); - - // nlog($file_path); - Storage::disk($this->disk)->put($file_path, $pdf); - - $path = Storage::disk($this->disk)->path($file_path); - $url = Storage::disk($this->disk)->url($file_path); - - info("disk = " . $this->disk); - info($path); - info($url); - + Storage::disk($this->disk)->put($file_path, $pdf); } catch(\Exception $e) diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index 3798d96cf919..d6cc1c82453b 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -112,8 +112,6 @@ class InvoiceEmailEngine extends BaseEmailEngine if ($this->client->getSetting('pdf_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { - CreateEntityPdf::dispatchNow($this->invitation); - if(Ninja::isHosted()) $this->setAttachments([$this->invoice->pdf_file_path($this->invitation, 'url', true)]); else