clean up for old email attachments

This commit is contained in:
David Bomba 2022-12-05 14:17:56 +11:00
parent 3869dcccf9
commit 46671e8fd5
3 changed files with 1 additions and 77 deletions

View File

@ -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']]);

View File

@ -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

View File

@ -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;