From 97a449e80ece3e553ec12064e74eae9e291f30f6 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 31 Oct 2024 12:50:13 -0700 Subject: [PATCH] removes instanceof User check --- app/Listeners/CheckoutableListener.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index cf9464a782..58ee68ea00 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -73,7 +73,7 @@ class CheckoutableListener * 2. The item has a EULA * 3. The item should send an email at check-in/check-out */ - if ($notifiable instanceof User) { + if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() || (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) { if (!empty($notifiable->email)) { @@ -83,7 +83,7 @@ class CheckoutableListener } Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default')); } - } + // Send Webhook notification if ($this->shouldSendWebhookNotification()) { Notification::route(Setting::getSettings()->webhook_selected, Setting::getSettings()->webhook_endpoint) @@ -145,13 +145,16 @@ class CheckoutableListener * 3. The item should send an email at check-in/check-out */ - if ($notifiable instanceof User && $notifiable->email != '') { if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() || (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) { - Mail::to($notifiable)->cc($ccEmails)->send($mailable); + if (!empty($notifiable->email)) { + Mail::to($notifiable)->cc($ccEmails)->send($mailable); + } else { + Mail::cc($ccEmails)->send($mailable); + } Log::info('Sending email, Locale: ' . $event->checkedOutTo->locale); } - } + // Send Webhook notification if ($this->shouldSendWebhookNotification()) { Notification::route(Setting::getSettings()->webhook_selected, Setting::getSettings()->webhook_endpoint)