diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 216245a3dbae..201c9134c901 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -722,7 +722,7 @@ public static function deprecationCheck() : array { $deprecations = [ 'ms_teams_deprecated' => array( 'check' => !Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'), - 'message' => 'The Microsoft Teams webhook URL being used will be deprecated Jan 31st, 2025. Change webhook endpoint'), + 'message' => 'The Microsoft Teams webhook URL being used was deprecated Jan 31st, 2025. Change webhook endpoint'), ]; // if item of concern is being used and its being used with the deprecated values return the notification array. diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php index 5524de9cec92..fd5c634856a1 100644 --- a/app/Listeners/CheckoutableListener.php +++ b/app/Listeners/CheckoutableListener.php @@ -95,12 +95,14 @@ public function onCheckedOut($event) // Send Webhook notification try { if ($this->shouldSendWebhookNotification()) { - if ($this->newMicrosoftTeamsWebhookEnabled()) { + if (Setting::getSettings()->webhook_selected === 'microsoft') { + if ($this->isDeprecatedTeamsWebhook()) { + return redirect()->back()->with('warning', trans('admin/settings/message.webhook.webhook_fail')); + } $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 } else { - Notification::route($this->webhookSelected(), Setting::getSettings()->webhook_endpoint) ->notify($this->getCheckoutNotification($event, $acceptance)); } @@ -192,7 +194,10 @@ public function onCheckedIn($event) // Send Webhook notification try { if ($this->shouldSendWebhookNotification()) { - if ($this->newMicrosoftTeamsWebhookEnabled()) { + if (Setting::getSettings()->webhook_selected === 'microsoft') { + if ($this->isDeprecatedTeamsWebhook()) { + return redirect()->back()->with('warning', trans('admin/settings/message.webhook.webhook_fail')); + } $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 @@ -381,8 +386,8 @@ private function checkoutableShouldSendEmail($event): bool return (method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email()); } - private function newMicrosoftTeamsWebhookEnabled(): bool + private function isDeprecatedTeamsWebhook(): bool { - return Setting::getSettings()->webhook_selected === 'microsoft' && Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'); + return !Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'); } } diff --git a/app/Livewire/SlackSettingsForm.php b/app/Livewire/SlackSettingsForm.php index 7487f30961b5..da224dd79a05 100644 --- a/app/Livewire/SlackSettingsForm.php +++ b/app/Livewire/SlackSettingsForm.php @@ -90,7 +90,7 @@ public function mount() { $this->isDisabled= ''; } if($this->webhook_selected === 'microsoft' && $this->teams_webhook_deprecated) { - session()->flash('warning', 'The selected Microsoft Teams webhook URL will be deprecated Jan 31st, 2025. Please use a workflow URL. Microsofts Documentation on creating a workflow can be found here.'); + session()->flash('warning', 'The selected Microsoft Teams webhook URL was deprecated Jan 31st, 2025. Please use a workflow URL. Microsofts Documentation on creating a workflow can be found here.'); } } public function updated($field) { @@ -247,23 +247,6 @@ public function googleWebhookTest(){ public function msTeamTestWebhook(){ try { - - if($this->teams_webhook_deprecated){ - //will use the deprecated webhook format - $payload = - [ - "@type" => "MessageCard", - "@context" => "http://schema.org/extensions", - "summary" => trans('mail.snipe_webhook_summary'), - "title" => trans('mail.snipe_webhook_test'), - "text" => trans('general.webhook_test_msg', ['app' => $this->webhook_name]), - ]; - $response = Http::withHeaders([ - 'content-type' => 'application/json', - ])->post($this->webhook_endpoint, - $payload)->throw(); - } - else { $notification = new TeamsNotification($this->webhook_endpoint); $message = trans('general.webhook_test_msg', ['app' => $this->webhook_name]); $notification->success()->sendMessage($message); @@ -271,7 +254,6 @@ public function msTeamTestWebhook(){ $response = Http::withHeaders([ 'content-type' => 'application/json', ])->post($this->webhook_endpoint); - } if(($response->getStatusCode() == 302)||($response->getStatusCode() == 301)){ return session()->flash('error' , trans('admin/settings/message.webhook.error_redirect', ['endpoint' => $this->webhook_endpoint])); diff --git a/app/Notifications/CheckinAccessoryNotification.php b/app/Notifications/CheckinAccessoryNotification.php index 28e6c054f7ad..72902c350c02 100644 --- a/app/Notifications/CheckinAccessoryNotification.php +++ b/app/Notifications/CheckinAccessoryNotification.php @@ -51,11 +51,6 @@ public function via() $notifyBy[] = GoogleChatChannel::class; } - if (Setting::getSettings()->webhook_selected == 'microsoft' && Setting::getSettings()->webhook_endpoint) { - - $notifyBy[] = MicrosoftTeamsChannel::class; - } - if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) { $notifyBy[] = SlackWebhookChannel::class; } @@ -92,19 +87,6 @@ public function toMicrosoftTeams() $admin = $this->admin; $item = $this->item; $note = $this->note; - if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - return MicrosoftTeamsMessage::create() - ->to($this->settings->webhook_endpoint) - ->type('success') - ->addStartGroupToSection('activityTitle') - ->title(trans('Accessory_Checkin_Notification')) - ->addStartGroupToSection('activityText') - ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle') - ->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '') - ->fact(trans('mail.Accessory_Checkin_Notification')." by ", $admin->present()->fullName()) - ->fact(trans('admin/consumables/general.remaining'), $item->numRemaining()) - ->fact(trans('mail.notes'), $note ?: ''); - } $message = trans('mail.Accessory_Checkin_Notification'); $details = [ diff --git a/app/Notifications/CheckinAssetNotification.php b/app/Notifications/CheckinAssetNotification.php index c6828ef8e921..9132b622490a 100644 --- a/app/Notifications/CheckinAssetNotification.php +++ b/app/Notifications/CheckinAssetNotification.php @@ -57,10 +57,6 @@ public function via() $notifyBy[] = GoogleChatChannel::class; } - if (Setting::getSettings()->webhook_selected == 'microsoft' && Setting::getSettings()->webhook_endpoint) { - - $notifyBy[] = MicrosoftTeamsChannel::class; - } if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) { Log::debug('use webhook'); $notifyBy[] = SlackWebhookChannel::class; @@ -99,20 +95,6 @@ public function toMicrosoftTeams() $item = $this->item; $note = $this->note; - if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - return MicrosoftTeamsMessage::create() - ->to($this->settings->webhook_endpoint) - ->type('success') - ->title(trans('mail.Asset_Checkin_Notification')) - ->addStartGroupToSection('activityText') - ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText') - ->fact(trans('mail.checked_into'), ($item->location) ? $item->location->name : '') - ->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName()) - ->fact(trans('admin/hardware/form.status'), $item->assetstatus?->name) - ->fact(trans('mail.notes'), $note ?: ''); - } - - $message = trans('mail.Asset_Checkin_Notification'); $details = [ trans('mail.asset') => htmlspecialchars_decode($item->present()->name), diff --git a/app/Notifications/CheckinLicenseSeatNotification.php b/app/Notifications/CheckinLicenseSeatNotification.php index 1cb8706e6716..bf332e3d6ba8 100644 --- a/app/Notifications/CheckinLicenseSeatNotification.php +++ b/app/Notifications/CheckinLicenseSeatNotification.php @@ -54,10 +54,6 @@ public function via() $notifyBy[] = GoogleChatChannel::class; } - if (Setting::getSettings()->webhook_selected == 'microsoft' && Setting::getSettings()->webhook_endpoint) { - - $notifyBy[] = MicrosoftTeamsChannel::class; - } if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) { $notifyBy[] = SlackWebhookChannel::class; @@ -103,19 +99,6 @@ public function toMicrosoftTeams() $admin = $this->admin; $item = $this->item; $note = $this->note; - if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - return MicrosoftTeamsMessage::create() - ->to($this->settings->webhook_endpoint) - ->type('success') - ->addStartGroupToSection('activityTitle') - ->title(trans('mail.License_Checkin_Notification')) - ->addStartGroupToSection('activityText') - ->fact(htmlspecialchars_decode($item->present()->name), '', 'header') - ->fact(trans('mail.License_Checkin_Notification')." by ", $admin->present()->fullName() ?: 'CLI tool') - ->fact(trans('mail.checkedin_from'), $target->present()->fullName()) - ->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count()) - ->fact(trans('mail.notes'), $note ?: ''); - } $message = trans('mail.License_Checkin_Notification'); $details = [ diff --git a/app/Notifications/CheckoutAccessoryNotification.php b/app/Notifications/CheckoutAccessoryNotification.php index 116a5ac29ff9..04d70e675dd6 100644 --- a/app/Notifications/CheckoutAccessoryNotification.php +++ b/app/Notifications/CheckoutAccessoryNotification.php @@ -50,11 +50,6 @@ public function via() $notifyBy[] = GoogleChatChannel::class; } - if (Setting::getSettings()->webhook_selected == 'microsoft' && Setting::getSettings()->webhook_endpoint) { - - $notifyBy[] = MicrosoftTeamsChannel::class; - } - if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) { $notifyBy[] = 'slack'; } @@ -121,22 +116,6 @@ public function toMicrosoftTeams() $item = $this->item; $note = $this->note; - if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - return MicrosoftTeamsMessage::create() - ->to($this->settings->webhook_endpoint) - ->type('success') - ->addStartGroupToSection('activityTitle') - ->title(trans('mail.Accessory_Checkout_Notification')) - ->addStartGroupToSection('activityText') - ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle') - ->fact(trans('mail.assigned_to'), $target->present()->name) - ->fact(trans('general.qty'), $this->checkout_qty) - ->fact(trans('mail.checkedout_from'), $item->location->name ? $item->location->name : '') - ->fact(trans('mail.Accessory_Checkout_Notification') . " by ", $admin->present()->fullName()) - ->fact(trans('admin/consumables/general.remaining'), $item->numRemaining()) - ->fact(trans('mail.notes'), $note ?: ''); - } - $message = trans('mail.Accessory_Checkout_Notification'); $details = [ trans('mail.assigned_to') => $target->present()->name, diff --git a/app/Notifications/CheckoutAssetNotification.php b/app/Notifications/CheckoutAssetNotification.php index 61499e62f2e6..a3db6bead56f 100644 --- a/app/Notifications/CheckoutAssetNotification.php +++ b/app/Notifications/CheckoutAssetNotification.php @@ -68,12 +68,6 @@ public function via() $notifyBy[] = GoogleChatChannel::class; } - if (Setting::getSettings()->webhook_selected === 'microsoft' && Setting::getSettings()->webhook_endpoint) { - - $notifyBy[] = MicrosoftTeamsChannel::class; - } - - if (Setting::getSettings()->webhook_selected === 'slack' || Setting::getSettings()->webhook_selected === 'general' ) { Log::debug('use webhook'); @@ -119,18 +113,6 @@ public function toMicrosoftTeams() $item = $this->item; $note = $this->note; - if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - return MicrosoftTeamsMessage::create() - ->to($this->settings->webhook_endpoint) - ->type('success') - ->title(trans('mail.Asset_Checkout_Notification')) - ->addStartGroupToSection('activityText') - ->fact(trans('mail.assigned_to'), $target->present()->name) - ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText') - ->fact(trans('mail.Asset_Checkout_Notification') . " by ", $admin->present()->fullName()) - ->fact(trans('mail.notes'), $note ?: ''); - } - $message = trans('mail.Asset_Checkout_Notification'); $details = [ trans('mail.assigned_to') => $target->present()->name, diff --git a/app/Notifications/CheckoutLicenseSeatNotification.php b/app/Notifications/CheckoutLicenseSeatNotification.php index 1aed0d200409..8d4982c50571 100644 --- a/app/Notifications/CheckoutLicenseSeatNotification.php +++ b/app/Notifications/CheckoutLicenseSeatNotification.php @@ -56,10 +56,6 @@ public function via() $notifyBy[] = GoogleChatChannel::class; } - if (Setting::getSettings()->webhook_selected == 'microsoft'){ - - $notifyBy[] = MicrosoftTeamsChannel::class; - } if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) { $notifyBy[] = SlackWebhookChannel::class; @@ -99,20 +95,6 @@ public function toMicrosoftTeams() $item = $this->item; $note = $this->note; - if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) { - return MicrosoftTeamsMessage::create() - ->to($this->settings->webhook_endpoint) - ->type('success') - ->addStartGroupToSection('activityTitle') - ->title(trans('mail.License_Checkout_Notification')) - ->addStartGroupToSection('activityText') - ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle') - ->fact(trans('mail.License_Checkout_Notification')." by ", $admin->present()->fullName()) - ->fact(trans('mail.assigned_to'), $target->present()->fullName()) - ->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count()) - ->fact(trans('mail.notes'), $note ?: ''); - } - $message = trans('mail.License_Checkout_Notification'); $details = [ trans('mail.assigned_to') => $target->present()->fullName(),