Skip to content

Commit 5084843

Browse files
authored
Merge pull request #15809 from marcusmoore/fixes/teams
Fixed Microsoft Teams notifications
2 parents 73383c6 + e80a456 commit 5084843

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app/Listeners/CheckoutableListener.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
use Illuminate\Support\Facades\Notification;
3232
use Exception;
3333
use Illuminate\Support\Facades\Log;
34+
use Illuminate\Support\Str;
3435
use Osama\LaravelTeamsNotification\TeamsNotification;
3536

3637
class CheckoutableListener
@@ -94,7 +95,7 @@ public function onCheckedOut($event)
9495
// Send Webhook notification
9596
try{
9697
if ($this->shouldSendWebhookNotification()) {
97-
if (Setting::getSettings()->webhook_selected === 'microsoft') {
98+
if ($this->newMicrosoftTeamsWebhookEnabled()) {
9899
$message = $this->getCheckoutNotification($event)->toMicrosoftTeams();
99100
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
100101
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
@@ -176,7 +177,7 @@ public function onCheckedIn($event)
176177
// Send Webhook notification
177178
try {
178179
if ($this->shouldSendWebhookNotification()) {
179-
if (Setting::getSettings()->webhook_selected === 'microsoft') {
180+
if ($this->newMicrosoftTeamsWebhookEnabled()) {
180181
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
181182
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
182183
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
@@ -345,4 +346,9 @@ private function checkoutableShouldSendEmail($event): bool
345346
}
346347
return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email());
347348
}
349+
350+
private function newMicrosoftTeamsWebhookEnabled(): bool
351+
{
352+
return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows');
353+
}
348354
}

app/Livewire/SlackSettingsForm.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ public function updatedWebhookSelected() {
114114
$this->webhook_channel = '#NA';
115115
}
116116
}
117-
public function updatedwebhookEndpoint() {
118-
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
119-
}
120-
public function updatedwebhookEndpoint() {
117+
118+
public function updatedwebhookEndpoint()
119+
{
121120
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
122121
}
123122

app/Notifications/CheckoutAssetNotification.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ public function toSlack() :SlackMessage
111111
->content($note);
112112
});
113113
}
114-
public function toMicrosoftTeams() : array
114+
115+
public function toMicrosoftTeams()
115116
{
116117
$target = $this->target;
117118
$admin = $this->admin;

0 commit comments

Comments
 (0)