From 18760e3fa19d4d37cf16995a4ba5f0b56ba3771a Mon Sep 17 00:00:00 2001 From: Godfrey M Date: Thu, 24 Oct 2024 12:21:51 -0700 Subject: [PATCH] replaces teams notification package, passes integration test --- app/Livewire/SlackSettingsForm.php | 22 ++- .../CheckoutAssetNotification.php | 4 +- composer.json | 2 +- composer.lock | 126 ++++++++++-------- 4 files changed, 79 insertions(+), 75 deletions(-) diff --git a/app/Livewire/SlackSettingsForm.php b/app/Livewire/SlackSettingsForm.php index 45b8b7b41e..758c2fdac8 100644 --- a/app/Livewire/SlackSettingsForm.php +++ b/app/Livewire/SlackSettingsForm.php @@ -7,7 +7,7 @@ use Illuminate\Support\Facades\Http; use Livewire\Component; use App\Models\Setting; use App\Helpers\Helper; - +use Osama\LaravelTeamsNotification\TeamsNotification; class SlackSettingsForm extends Component { public $webhook_endpoint; @@ -236,20 +236,14 @@ class SlackSettingsForm extends Component } public function msTeamTestWebhook(){ - $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]), - ]; - try { - $response = Http::withHeaders([ - 'content-type' => 'applications/json', - ])->post($this->webhook_endpoint, - $payload)->throw(); + $notification = new TeamsNotification($this->webhook_endpoint); + $message = trans('general.webhook_test_msg', ['app' => $this->webhook_name]); + $notification->success()->sendMessage($message); + + $response = Http::withHeaders([ + 'content-type' => 'applications/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/CheckoutAssetNotification.php b/app/Notifications/CheckoutAssetNotification.php index b14796fb8c..b479e00335 100644 --- a/app/Notifications/CheckoutAssetNotification.php +++ b/app/Notifications/CheckoutAssetNotification.php @@ -21,6 +21,8 @@ use NotificationChannels\GoogleChat\Widgets\KeyValue; use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel; use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage; use Illuminate\Support\Facades\Log; +use Osama\LaravelTeamsNotification\TeamsNotification; + class CheckoutAssetNotification extends Notification { use Queueable; @@ -69,7 +71,7 @@ class CheckoutAssetNotification extends Notification if (Setting::getSettings()->webhook_selected == 'microsoft' && Setting::getSettings()->webhook_endpoint) { - $notifyBy[] = MicrosoftTeamsChannel::class; + $notifyBy[] = TeamsNotification::class; } diff --git a/composer.json b/composer.json index d3637c3a4b..b6aceaaa70 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,6 @@ "intervention/image": "^2.5", "javiereguiluz/easyslugger": "^1.0", "laravel-notification-channels/google-chat": "^3.0", - "laravel-notification-channels/microsoft-teams": "^1.1", "laravel/framework": "^10.0", "laravel/helpers": "^1.4", "laravel/passport": "^11.0", @@ -55,6 +54,7 @@ "nunomaduro/collision": "^7.0", "okvpn/clock-lts": "^1.0", "onelogin/php-saml": "^3.4", + "osa-eg/laravel-teams-notification": "^2.1", "paragonie/constant_time_encoding": "^2.3", "paragonie/sodium_compat": "^1.19", "phpdocumentor/reflection-docblock": "^5.1", diff --git a/composer.lock b/composer.lock index 0631fc275e..877082bd2b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "5341bc5be02b3c33e28e46e06dd99f29", + "content-hash": "6eb153ab8627da9552bc84de32665f0f", "packages": [ { "name": "alek13/slack", @@ -2623,63 +2623,6 @@ }, "time": "2024-03-19T06:42:00+00:00" }, - { - "name": "laravel-notification-channels/microsoft-teams", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/laravel-notification-channels/microsoft-teams.git", - "reference": "41d054c5f603ca10951144a87eb8e9652307ce1b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/laravel-notification-channels/microsoft-teams/zipball/41d054c5f603ca10951144a87eb8e9652307ce1b", - "reference": "41d054c5f603ca10951144a87eb8e9652307ce1b", - "shasum": "" - }, - "require": { - "guzzlehttp/guzzle": "^6.3 || ^7.0", - "illuminate/notifications": "~5.5 || ~6.0 || ~7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0", - "illuminate/support": "~5.5 || ~6.0 || ~7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0", - "php": ">=7.2" - }, - "require-dev": { - "mockery/mockery": "^1.2.3", - "phpunit/phpunit": "^8.0 || ^9.5 || ^10.5" - }, - "type": "library", - "extra": { - "laravel": { - "providers": [ - "NotificationChannels\\MicrosoftTeams\\MicrosoftTeamsServiceProvider" - ] - } - }, - "autoload": { - "psr-4": { - "NotificationChannels\\MicrosoftTeams\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Tobias Madner", - "email": "tobias.madner@gmx.at", - "homepage": "https://www.pinpoll.com", - "role": "Developer" - } - ], - "description": "A Laravel Notification Channel for Microsoft Teams", - "homepage": "https://github.com/laravel-notification-channels/microsoft-teams", - "support": { - "issues": "https://github.com/laravel-notification-channels/microsoft-teams/issues", - "source": "https://github.com/laravel-notification-channels/microsoft-teams/tree/1.2.0" - }, - "time": "2024-03-11T15:07:16+00:00" - }, { "name": "laravel/framework", "version": "v10.48.22", @@ -5572,6 +5515,71 @@ ], "time": "2024-05-30T15:14:26+00:00" }, + { + "name": "osa-eg/laravel-teams-notification", + "version": "v2.1.2", + "source": { + "type": "git", + "url": "https://github.com/osa-eg/laravel-teams-notification.git", + "reference": "76173689930aca92b5174a3b102e705279192c0f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/osa-eg/laravel-teams-notification/zipball/76173689930aca92b5174a3b102e705279192c0f", + "reference": "76173689930aca92b5174a3b102e705279192c0f", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": ">=6.5", + "illuminate/support": "^5.5 || ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0", + "monolog/monolog": ">=1.0", + "php": ">=7.0" + }, + "require-dev": { + "phpunit/phpunit": "^8.5" + }, + "type": "library", + "extra": { + "laravel": { + "providers": [ + "Osama\\LaravelTeamsNotification\\LaravelTeamsNotificationServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Osama\\LaravelTeamsNotification\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Osama Saad", + "email": "osaad96eg@gmail.com" + } + ], + "description": "A Laravel package to send notifications to Microsoft Teams", + "keywords": [ + "Teams", + "adaptive-card", + "laravel", + "logging", + "microsoft-teams-workflow", + "notification", + "teams-connector", + "teams-webhock", + "teams-workflow", + "teams_logging" + ], + "support": { + "issues": "https://github.com/osa-eg/laravel-teams-notification/issues", + "source": "https://github.com/osa-eg/laravel-teams-notification/tree/v2.1.2" + }, + "time": "2024-09-23T05:24:48+00:00" + }, { "name": "paragonie/constant_time_encoding", "version": "v2.7.0", @@ -16504,5 +16512,5 @@ "ext-pdo": "*" }, "platform-dev": [], - "plugin-api-version": "2.6.0" + "plugin-api-version": "2.3.0" }