Move notification sending into try catch block

This commit is contained in:
Marcus Moore 2023-04-19 12:26:48 -07:00
parent 15280c435e
commit 835f8876c4
No known key found for this signature in database

View file

@ -37,19 +37,18 @@ class CheckoutableListener
return; 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 * Make a checkout acceptance and attach it in the notification
*/ */
$acceptance = $this->getCheckoutAcceptance($event); $acceptance = $this->getCheckoutAcceptance($event);
try { 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) { if (! $event->checkedOutTo->locale) {
Notification::locale(Setting::getSettings()->locale)->send( Notification::locale(Setting::getSettings()->locale)->send(
$this->getNotifiables($event), $this->getNotifiables($event),
@ -77,12 +76,6 @@ class CheckoutableListener
return; 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 * Send the appropriate notification
*/ */
@ -97,6 +90,12 @@ class CheckoutableListener
} }
try { 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 // Use default locale
if (! $event->checkedOutTo->locale) { if (! $event->checkedOutTo->locale) {
Notification::locale(Setting::getSettings()->locale)->send( Notification::locale(Setting::getSettings()->locale)->send(