From ed81973fe649355a687dfd5dc70b60d9fdb997c3 Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Mon, 28 Oct 2024 13:57:42 -0700 Subject: [PATCH] adds notifications for deprecation --- app/Helpers/Helper.php | 18 ++++++++++++++++++ app/Livewire/SlackSettingsForm.php | 13 ++++++++----- resources/views/layouts/default.blade.php | 9 ++++++--- .../livewire/slack-settings-form.blade.php | 9 ++++++++- 4 files changed, 40 insertions(+), 9 deletions(-) diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index 6c43fec05a19..d70d169be24f 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -16,6 +16,7 @@ use Illuminate\Contracts\Encryption\DecryptException; use Carbon\Carbon; use Illuminate\Support\Facades\Log; +use Illuminate\Support\Str; use Intervention\Image\ImageManagerStatic as Image; use Illuminate\Support\Facades\Session; @@ -708,6 +709,23 @@ public static function generateRandomString($length = 10) return $randomString; } + /** + * A method to be used to handle deprecations and giving notifications, currently handling MS Teams. more can be added when needed. + * + * + * @author [Godfrey Martinez] + * @since [v7.0.14] + * @return array + */ + public static function deprecationCheck(){ + $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 your webhook URL'), + ]; + + return $deprecations; + } /** * This nasty little method gets the low inventory info for the diff --git a/app/Livewire/SlackSettingsForm.php b/app/Livewire/SlackSettingsForm.php index 57f811c3d1a2..3be8aa627e15 100644 --- a/app/Livewire/SlackSettingsForm.php +++ b/app/Livewire/SlackSettingsForm.php @@ -81,15 +81,17 @@ public function mount() { $this->webhook_channel = $this->setting->webhook_channel; $this->webhook_botname = $this->setting->webhook_botname; $this->webhook_options = $this->setting->webhook_selected; - if($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){ + $this->teams_webhook_deprecated = Str::contains($this->webhook_endpoint, 'workflows'); + if($this->webhook_selected === 'microsoft' || $this->webhook_selected === 'google'){ $this->webhook_channel = '#NA'; } - if($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null){ $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.'); + } } public function updated($field) { @@ -111,7 +113,6 @@ public function updatedWebhookSelected() { if($this->webhook_selected == 'microsoft' || $this->webhook_selected == 'google'){ $this->webhook_channel = '#NA'; } - } private function isButtonDisabled() { @@ -128,7 +129,9 @@ private function isButtonDisabled() { public function render() { $this->isButtonDisabled(); + return view('livewire.slack-settings-form'); + } public function testWebhook(){ @@ -237,7 +240,7 @@ public function googleWebhookTest(){ } } public function msTeamTestWebhook(){ - $this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows'); + try { if($this->teams_webhook_deprecated){ diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php index 1bf7db6f652a..46341f70cc08 100644 --- a/resources/views/layouts/default.blade.php +++ b/resources/views/layouts/default.blade.php @@ -268,17 +268,20 @@ @can('admin') @if ($snipeSettings->show_alerts_in_menu=='1') - +