mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-21 03:15:45 -08:00
Add conditional for microsoft team integration version
This commit is contained in:
parent
ac3ae651b1
commit
c399d797b4
|
@ -31,6 +31,7 @@ use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
use Osama\LaravelTeamsNotification\TeamsNotification;
|
use Osama\LaravelTeamsNotification\TeamsNotification;
|
||||||
|
|
||||||
class CheckoutableListener
|
class CheckoutableListener
|
||||||
|
@ -94,7 +95,7 @@ class CheckoutableListener
|
||||||
// Send Webhook notification
|
// Send Webhook notification
|
||||||
try{
|
try{
|
||||||
if ($this->shouldSendWebhookNotification()) {
|
if ($this->shouldSendWebhookNotification()) {
|
||||||
if (Setting::getSettings()->webhook_selected === 'microsoft') {
|
if ($this->newMicrosoftTeamsWebhookEnabled()) {
|
||||||
$message = $this->getCheckoutNotification($event)->toMicrosoftTeams();
|
$message = $this->getCheckoutNotification($event)->toMicrosoftTeams();
|
||||||
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
|
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
|
||||||
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
|
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
|
||||||
|
@ -176,7 +177,7 @@ class CheckoutableListener
|
||||||
// Send Webhook notification
|
// Send Webhook notification
|
||||||
try {
|
try {
|
||||||
if ($this->shouldSendWebhookNotification()) {
|
if ($this->shouldSendWebhookNotification()) {
|
||||||
if (Setting::getSettings()->webhook_selected === 'microsoft') {
|
if ($this->newMicrosoftTeamsWebhookEnabled()) {
|
||||||
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
|
$message = $this->getCheckinNotification($event)->toMicrosoftTeams();
|
||||||
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
|
$notification = new TeamsNotification(Setting::getSettings()->webhook_endpoint);
|
||||||
$notification->success()->sendMessage($message[0], $message[1]); // Send the message to Microsoft Teams
|
$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());
|
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');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue