try/catch wrap notifications on checkin/checkout

This commit is contained in:
Brady Wetherington 2022-09-15 13:18:42 -07:00
parent 51d7f2b97b
commit 1899e4d1e8

View file

@ -20,6 +20,8 @@ use App\Notifications\CheckoutConsumableNotification;
use App\Notifications\CheckoutLicenseNotification; use App\Notifications\CheckoutLicenseNotification;
use App\Notifications\CheckoutLicenseSeatNotification; use App\Notifications\CheckoutLicenseSeatNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Exception;
use Log;
class CheckoutableListener class CheckoutableListener
{ {
@ -43,16 +45,20 @@ class CheckoutableListener
*/ */
$acceptance = $this->getCheckoutAcceptance($event); $acceptance = $this->getCheckoutAcceptance($event);
if (! $event->checkedOutTo->locale) { try {
Notification::locale(Setting::getSettings()->locale)->send( if (! $event->checkedOutTo->locale) {
$this->getNotifiables($event), Notification::locale(Setting::getSettings()->locale)->send(
$this->getCheckoutNotification($event, $acceptance) $this->getNotifiables($event),
); $this->getCheckoutNotification($event, $acceptance)
} else { );
Notification::send( } else {
$this->getNotifiables($event), Notification::send(
$this->getCheckoutNotification($event, $acceptance) $this->getNotifiables($event),
); $this->getCheckoutNotification($event, $acceptance)
);
}
} catch (Exception $e) {
Log::error("Exception caught during checkout notification: ".$e->getMessage());
} }
} }
@ -83,17 +89,21 @@ class CheckoutableListener
} }
} }
// Use default locale try {
if (! $event->checkedOutTo->locale) { // Use default locale
Notification::locale(Setting::getSettings()->locale)->send( if (! $event->checkedOutTo->locale) {
$this->getNotifiables($event), Notification::locale(Setting::getSettings()->locale)->send(
$this->getCheckinNotification($event) $this->getNotifiables($event),
); $this->getCheckinNotification($event)
} else { );
Notification::send( } else {
$this->getNotifiables($event), Notification::send(
$this->getCheckinNotification($event) $this->getNotifiables($event),
); $this->getCheckinNotification($event)
);
}
} catch (Exception $e) {
Log::error("Exception caught during checkin notification: ".$e->getMessage());
} }
} }