Skip to content

Commit 7ad01da

Browse files
committed
redid url check
1 parent c4a26fc commit 7ad01da

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

app/Listeners/CheckoutableListener.php

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,13 @@ public function onCheckedOut($event)
9494
}
9595
// Send Webhook notification
9696
try {
97-
if ($this->shouldSendWebhookNotification()) {
98-
if ($this->newMicrosoftTeamsWebhookEnabled()) {
99-
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')){
100-
return redirect()->back()->with('warning',trans('admin/settings/message.webhook.webhook_fail'));
101-
}
102-
$message = $this->getCheckoutNotification($event)->toMicrosoftTeams();
103-
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
104-
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
97+
if ($this->shouldSendWebhookNotification()){
98+
if($this->isDeprecatedTeamsWebhook()){
99+
return redirect()->back()->with('warning',trans('admin/settings/message.webhook.webhook_fail'));
105100
}
101+
$message = $this->getCheckoutNotification($event)->toMicrosoftTeams();
102+
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
103+
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
106104
}
107105
} catch (ClientException $e) {
108106
if (strpos($e->getMessage(), 'channel_not_found') !== false) {
@@ -190,15 +188,13 @@ public function onCheckedIn($event)
190188

191189
// Send Webhook notification
192190
try {
193-
if ($this->shouldSendWebhookNotification()) {
194-
if ($this->newMicrosoftTeamsWebhookEnabled()) {
195-
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')){
196-
return redirect()->back()->with('warning',trans('admin/settings/message.webhook.webhook_fail'));
197-
}
198-
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
199-
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
200-
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
191+
if ($this->shouldSendWebhookNotification()){
192+
if($this->isDeprecatedTeamsWebhook()){
193+
return redirect()->back()->with('warning',trans('admin/settings/message.webhook.webhook_fail'));
201194
}
195+
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
196+
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
197+
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
202198
}
203199
} catch (ClientException $e) {
204200
if (strpos($e->getMessage(), 'channel_not_found') !== false) {
@@ -380,8 +376,8 @@ private function checkoutableShouldSendEmail($event): bool
380376
return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email());
381377
}
382378

383-
private function newMicrosoftTeamsWebhookEnabled(): bool
379+
private function isDeprecatedTeamsWebhook(): bool
384380
{
385-
return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows');
381+
return !Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows');
386382
}
387383
}

0 commit comments

Comments
 (0)