Skip to content

Commit ebe07c2

Browse files
committed
removed too much code, tests pass
1 parent 7ad01da commit ebe07c2

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

app/Listeners/CheckoutableListener.php

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,18 @@ public function onCheckedOut($event)
9494
}
9595
// Send Webhook notification
9696
try {
97-
if ($this->shouldSendWebhookNotification()){
98-
if($this->isDeprecatedTeamsWebhook()){
99-
return redirect()->back()->with('warning',trans('admin/settings/message.webhook.webhook_fail'));
97+
if ($this->shouldSendWebhookNotification()) {
98+
if (Setting::getSettings()->webhook_selected === 'microsoft') {
99+
if ($this->isDeprecatedTeamsWebhook()) {
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
105+
} else {
106+
Notification::route($this->webhookSelected(), Setting::getSettings()->webhook_endpoint)
107+
->notify($this->getCheckoutNotification($event, $acceptance));
100108
}
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
104109
}
105110
} catch (ClientException $e) {
106111
if (strpos($e->getMessage(), 'channel_not_found') !== false) {
@@ -188,13 +193,18 @@ public function onCheckedIn($event)
188193

189194
// Send Webhook notification
190195
try {
191-
if ($this->shouldSendWebhookNotification()){
192-
if($this->isDeprecatedTeamsWebhook()){
193-
return redirect()->back()->with('warning',trans('admin/settings/message.webhook.webhook_fail'));
196+
if ($this->shouldSendWebhookNotification()) {
197+
if (Setting::getSettings()->webhook_selected === 'microsoft') {
198+
if ($this->isDeprecatedTeamsWebhook()) {
199+
return redirect()->back()->with('warning', trans('admin/settings/message.webhook.webhook_fail'));
200+
}
201+
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
202+
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
203+
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
204+
} else {
205+
Notification::route($this->webhookSelected(), Setting::getSettings()->webhook_endpoint)
206+
->notify($this->getCheckinNotification($event));
194207
}
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
198208
}
199209
} catch (ClientException $e) {
200210
if (strpos($e->getMessage(), 'channel_not_found') !== false) {

0 commit comments

Comments
 (0)