|
31 | 31 | use Illuminate\Support\Facades\Notification; |
32 | 32 | use Exception; |
33 | 33 | use Illuminate\Support\Facades\Log; |
| 34 | +use Illuminate\Support\Str; |
34 | 35 | use Osama\LaravelTeamsNotification\TeamsNotification; |
35 | 36 |
|
36 | 37 | class CheckoutableListener |
@@ -94,7 +95,7 @@ public function onCheckedOut($event) |
94 | 95 | // Send Webhook notification |
95 | 96 | try{ |
96 | 97 | if ($this->shouldSendWebhookNotification()) { |
97 | | - if (Setting::getSettings()->webhook_selected === 'microsoft') { |
| 98 | + if ($this->newMicrosoftTeamsWebhookEnabled()) { |
98 | 99 | $message = $this->getCheckoutNotification($event)->toMicrosoftTeams(); |
99 | 100 | $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); |
100 | 101 | $notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams |
@@ -176,7 +177,7 @@ public function onCheckedIn($event) |
176 | 177 | // Send Webhook notification |
177 | 178 | try { |
178 | 179 | if ($this->shouldSendWebhookNotification()) { |
179 | | - if (Setting::getSettings()->webhook_selected === 'microsoft') { |
| 180 | + if ($this->newMicrosoftTeamsWebhookEnabled()) { |
180 | 181 | $message = $this->getCheckinNotification($event)->toMicrosoftTeams(); |
181 | 182 | $notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint); |
182 | 183 | $notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams |
@@ -345,4 +346,9 @@ private function checkoutableShouldSendEmail($event): bool |
345 | 346 | } |
346 | 347 | return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email()); |
347 | 348 | } |
| 349 | + |
| 350 | + private function newMicrosoftTeamsWebhookEnabled(): bool |
| 351 | + { |
| 352 | + return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'); |
| 353 | + } |
348 | 354 | } |
0 commit comments