From 46671e8fd54cf6eccfc047cb99e4ce186dcb5313 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Mon, 5 Dec 2022 14:17:56 +1100 Subject: [PATCH] clean up for old email attachments --- app/Mail/Engine/InvoiceEmailEngine.php | 7 +---- app/Mail/TemplateEmail.php | 41 -------------------------- app/Mail/VendorTemplateEmail.php | 30 ------------------- 3 files changed, 1 insertion(+), 77 deletions(-) diff --git a/app/Mail/Engine/InvoiceEmailEngine.php b/app/Mail/Engine/InvoiceEmailEngine.php index 69810ba626ca..f19d156ebc01 100644 --- a/app/Mail/Engine/InvoiceEmailEngine.php +++ b/app/Mail/Engine/InvoiceEmailEngine.php @@ -127,12 +127,7 @@ class InvoiceEmailEngine extends BaseEmailEngine ->setTextBody($text_body); if ($this->client->getSetting('pdf_email_attachment') !== false && $this->invoice->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) { - // if (Ninja::isHosted()) { - // $this->setAttachments([$this->invoice->pdf_file_path($this->invitation, 'url', true)]); - // } else { - // $this->setAttachments([$this->invoice->pdf_file_path($this->invitation)]); - // } - // $file = (new CreateRawPdf($invitation, $invitation->company->db))->handle(); + $pdf = ((new CreateRawPdf($this->invitation, $this->invitation->company->db))->handle()); $this->setAttachments([['file' => base64_encode($pdf), 'name' => $this->invoice->numberFormatter().'.pdf']]); diff --git a/app/Mail/TemplateEmail.php b/app/Mail/TemplateEmail.php index b5b443657f78..aad3ec35c48e 100644 --- a/app/Mail/TemplateEmail.php +++ b/app/Mail/TemplateEmail.php @@ -118,50 +118,9 @@ class TemplateEmail extends Mailable 'logo' => $this->company->present()->logo($settings), ]); - /*In the hosted platform we need to slow things down a little for Storage to catch up.*/ - - // if(Ninja::isHosted() && $this->invitation){ - - // $path = false; - - // if($this->invitation->invoice) - // $path = $this->client->invoice_filepath($this->invitation).$this->invitation->invoice->numberFormatter().'.pdf'; - // elseif($this->invitation->quote) - // $path = $this->client->quote_filepath($this->invitation).$this->invitation->quote->numberFormatter().'.pdf'; - // elseif($this->invitation->credit) - // $path = $this->client->credit_filepath($this->invitation).$this->invitation->credit->numberFormatter().'.pdf'; - - // sleep(1); - - // if($path && !Storage::disk(config('filesystems.default'))->exists($path)){ - - // sleep(2); - - // if(!Storage::disk(config('filesystems.default'))->exists($path)) { - // (new CreateEntityPdf($this->invitation))->handle(); - // sleep(2); - // } - - // } - - // } - - // $file = (new CreateRawPdf($invitation, $invitation->company->db))->handle(); - //22-10-2022 - Performance - To improve the performance/reliability of sending emails, attaching as Data is much better, stubs in place foreach ($this->build_email->getAttachments() as $file) { - // if (is_string($file)) { - // // nlog($file); - // // $file_data = file_get_contents($file); - // // $this->attachData($file_data, basename($file)); - // $this->attach($file); - // } elseif (is_array($file)) { - // // nlog($file['path']); - // // $file_data = file_get_contents($file['path']); - // // $this->attachData($file_data, $file['name']); - // $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]); - // } if(array_key_exists('file', $file)) $this->attachData(base64_decode($file['file']), $file['name']); else diff --git a/app/Mail/VendorTemplateEmail.php b/app/Mail/VendorTemplateEmail.php index 1ed0ca78f279..0b9e8d1cc835 100644 --- a/app/Mail/VendorTemplateEmail.php +++ b/app/Mail/VendorTemplateEmail.php @@ -112,43 +112,13 @@ class VendorTemplateEmail extends Mailable ]); - // if(Ninja::isHosted() && $this->invitation){ - - // $path = false; - - // if($this->invitation->purchase_order) - // $path = $this->vendor->purchase_order_filepath($this->invitation).$this->invitation->purchase_order->numberFormatter().'.pdf'; - - // sleep(1); - - // if($path && !Storage::disk(config('filesystems.default'))->exists($path)){ - - // sleep(2); - - // if(!Storage::disk(config('filesystems.default'))->exists($path)) { - // (new CreatePurchaseOrderPdf($this->invitation))->handle(); - // sleep(2); - // } - - // } - - // } - foreach ($this->build_email->getAttachments() as $file) { - // if (is_string($file)) { - // $this->attach($file); - // } elseif (is_array($file)) { - // $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]); - // } - - // $this->attachData(base64_decode($file['file']), $file['name']); if(array_key_exists('file', $file)) $this->attachData(base64_decode($file['file']), $file['name']); else $this->attach($file['path'], ['as' => $file['name'], 'mime' => null]); - } return $this;