Merge pull request #15809 from marcusmoore/fixes/teams

Fixed Microsoft Teams notifications
This commit is contained in:
snipe 2024-11-13 22:38:24 +00:00 committed by GitHub
commit 5084843f9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 7 deletions

View file

@ -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');
}
}

View file

@ -114,10 +114,9 @@ class SlackSettingsForm extends Component
$this->webhook_channel = '#NA';
}
}
public function updatedwebhookEndpoint() {
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
}
public function updatedwebhookEndpoint() {
public function updatedwebhookEndpoint()
{
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
}

View file

@ -111,7 +111,8 @@ class CheckoutAssetNotification extends Notification
->content($note);
});
}
public function toMicrosoftTeams() : array
public function toMicrosoftTeams()
{
$target = $this->target;
$admin = $this->admin;