From cdb99be032869ff58784a545b84b4f4ba237b67c Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 29 Apr 2025 09:17:03 +1000 Subject: [PATCH] Logging for showblob --- app/Jobs/Mail/NinjaMailerJob.php | 15 ++++++++++++++- app/Models/Document.php | 5 ++++- app/Services/Email/Email.php | 13 ++++++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/Jobs/Mail/NinjaMailerJob.php b/app/Jobs/Mail/NinjaMailerJob.php index e561517014..33628d7f9b 100644 --- a/app/Jobs/Mail/NinjaMailerJob.php +++ b/app/Jobs/Mail/NinjaMailerJob.php @@ -210,7 +210,20 @@ class NinjaMailerJob implements ShouldQueue } - } catch (\Exception $e) { + } catch(\ErrorException $e){ + + nlog("indeed i am a error exception NinjaMailerJob"); + + $message = "Attachment size is too large."; + $this->fail(); + $this->logMailError($message, $this->company->clients()->first()); + $this->entityEmailFailed($message); + $this->cleanUpMailers(); + + return; + + } + catch (\Exception $e) { nlog("Mailer failed with {$e->getMessage()}"); $message = $e->getMessage(); diff --git a/app/Models/Document.php b/app/Models/Document.php index 7e40cf718e..e32a7c4dfd 100644 --- a/app/Models/Document.php +++ b/app/Models/Document.php @@ -248,12 +248,14 @@ class Document extends BaseModel } try { - $file = base64_encode($image); + // $file = base64_encode($image); + $file = $image; $img = new \Imagick(); //@phpstan-ignore-line $img->readImageBlob($file); $img->setImageCompression(true); //@phpstan-ignore-line $img->setImageCompressionQuality(40); + $img->stripImage(); return $img->getImageBlob(); @@ -265,6 +267,7 @@ class Document extends BaseModel } + /** * Returns boolean based on checks for image. * diff --git a/app/Services/Email/Email.php b/app/Services/Email/Email.php index 237443bdd0..e300188ae5 100644 --- a/app/Services/Email/Email.php +++ b/app/Services/Email/Email.php @@ -346,7 +346,18 @@ class Email implements ShouldQueue $message = null; } - } catch (\Exception | \RuntimeException $e) { + } catch(\ErrorException $e){ + nlog("indeed i am a error exception Email Class"); + $message = "Attachment size is too large."; + $this->fail(); + $this->logMailError($message, $this->company->clients()->first()); + $this->cleanUpMailers(); + + $this->entityEmailFailed($message); + + return; + } + catch (\Exception | \RuntimeException $e) { nlog("Mailer failed with {$e->getMessage()}"); $message = $e->getMessage();