From 338e7a0037731a8b08fc7d66dbc932e5d33799ae Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 26 Dec 2023 14:57:36 +1100 Subject: [PATCH] Notify on bounced account creation email --- app/Jobs/PostMark/ProcessPostmarkWebhook.php | 8 ++++++-- app/Mail/Admin/VerifyUserObject.php | 1 - app/Notifications/Ninja/EmailBounceNotification.php | 10 ++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/Jobs/PostMark/ProcessPostmarkWebhook.php b/app/Jobs/PostMark/ProcessPostmarkWebhook.php index b2152c8eb017..ea9db0590c16 100644 --- a/app/Jobs/PostMark/ProcessPostmarkWebhook.php +++ b/app/Jobs/PostMark/ProcessPostmarkWebhook.php @@ -30,6 +30,7 @@ use Illuminate\Foundation\Bus\Dispatchable; use App\DataMapper\Analytics\Mail\EmailSpam; use App\DataMapper\Analytics\Mail\EmailBounce; use App\Notifications\Ninja\EmailSpamNotification; +use App\Notifications\Ninja\EmailBounceNotification; class ProcessPostmarkWebhook implements ShouldQueue { @@ -103,6 +104,11 @@ class ProcessPostmarkWebhook implements ShouldQueue case 'Delivery': return $this->processDelivery(); case 'Bounce': + + if($this->request['Subject'] == ctrans('texts.confirmation_subject')) { + $company->notification(new EmailBounceNotification($this->request['Email']))->ninja(); + } + return $this->processBounce(); case 'SpamComplaint': return $this->processSpamComplaint(); @@ -263,8 +269,6 @@ class ProcessPostmarkWebhook implements ShouldQueue (new SystemLogger($data, SystemLog::CATEGORY_MAIL, SystemLog::EVENT_MAIL_BOUNCED, SystemLog::TYPE_WEBHOOK_RESPONSE, $this->invitation->contact->client, $this->invitation->company))->handle(); - // if(config('ninja.notification.slack')) - // $this->invitation->company->notification(new EmailBounceNotification($this->invitation->company->account))->ninja(); } // { diff --git a/app/Mail/Admin/VerifyUserObject.php b/app/Mail/Admin/VerifyUserObject.php index 283ce803da55..602be330eb46 100644 --- a/app/Mail/Admin/VerifyUserObject.php +++ b/app/Mail/Admin/VerifyUserObject.php @@ -42,7 +42,6 @@ class VerifyUserObject if($this->is_react) { $react_redirect = '?react=true'; - nlog("is react"); } $data = [ diff --git a/app/Notifications/Ninja/EmailBounceNotification.php b/app/Notifications/Ninja/EmailBounceNotification.php index 4ae6966d725a..40e919155bbc 100644 --- a/app/Notifications/Ninja/EmailBounceNotification.php +++ b/app/Notifications/Ninja/EmailBounceNotification.php @@ -21,11 +21,9 @@ class EmailBounceNotification extends Notification * * @return void */ - protected $account; - public function __construct($account) + public function __construct(private string $email_address) { - $this->account = $account; } /** @@ -64,11 +62,7 @@ class EmailBounceNotification extends Notification public function toSlack($notifiable) { - $content = "Email bounce notification for Account {$this->account->key} \n"; - - $owner = $this->account->companies()->first()->owner(); - - $content .= "Owner {$owner->present()->name() } | {$owner->email}"; + $content = "Email bounce notification for {$this->email_address} \n"; return (new SlackMessage) ->success()