From 835f8876c4a7705534205c81892d2ba5bcbed9e8 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 19 Apr 2023 12:26:48 -0700 Subject: [PATCH] Move notification sending into try catch block --- app/Listeners/CheckoutableListener.php | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 01d74df85d..6099c8f2e3 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -37,19 +37,18 @@ class CheckoutableListener return; } - // Send an anonymous webhook notification if setting enabled - if ($this->shouldSendWebhookNotification()) { - Notification::route('slack', Setting::getSettings()->webhook_endpoint) - ->notify($this->getCheckoutNotification($event)); - } - /** * Make a checkout acceptance and attach it in the notification */ $acceptance = $this->getCheckoutAcceptance($event); try { - // @todo: wrap notification above in this try + // Send an anonymous webhook notification if setting enabled + if ($this->shouldSendWebhookNotification()) { + Notification::route('slack', Setting::getSettings()->webhook_endpoint) + ->notify($this->getCheckoutNotification($event)); + } + if (! $event->checkedOutTo->locale) { Notification::locale(Setting::getSettings()->locale)->send( $this->getNotifiables($event), @@ -77,12 +76,6 @@ class CheckoutableListener return; } - // Send an anonymous webhook notification if setting enabled - if ($this->shouldSendWebhookNotification()) { - Notification::route('slack', Setting::getSettings()->webhook_endpoint) - ->notify($this->getCheckinNotification($event)); - } - /** * Send the appropriate notification */ @@ -97,6 +90,12 @@ class CheckoutableListener } try { + // Send an anonymous webhook notification if setting enabled + if ($this->shouldSendWebhookNotification()) { + Notification::route('slack', Setting::getSettings()->webhook_endpoint) + ->notify($this->getCheckinNotification($event)); + } + // Use default locale if (! $event->checkedOutTo->locale) { Notification::locale(Setting::getSettings()->locale)->send(