diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index c5499784b7..6037ee1ec4 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\Notification; use Exception; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Str; use Osama\LaravelTeamsNotification\TeamsNotification; class CheckoutableListener @@ -94,7 +95,7 @@ class CheckoutableListener // Send Webhook notification try{ if ($this->shouldSendWebhookNotification()) { - if (Setting::getSettings()->webhook_selected === 'microsoft') { + if ($this->newMicrosoftTeamsWebhookEnabled()) { $message = $this->getCheckoutNotification($event)->toMicrosoftTeams(); $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); $notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams @@ -176,7 +177,7 @@ class CheckoutableListener // Send Webhook notification try { if ($this->shouldSendWebhookNotification()) { - if (Setting::getSettings()->webhook_selected === 'microsoft') { + if ($this->newMicrosoftTeamsWebhookEnabled()) { $message = $this->getCheckinNotification($event)->toMicrosoftTeams(); $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); $notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams @@ -345,4 +346,9 @@ class CheckoutableListener } return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email()); } + + private function newMicrosoftTeamsWebhookEnabled(): bool + { + return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'); + } }