Skip to content

Commit c0620c2

Browse files
committed
adds back laravels channel formats
1 parent ed81973 commit c0620c2

10 files changed

+106
-6
lines changed

app/Helpers/Helper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,18 @@ public static function generateRandomString($length = 10)
718718
* @return array
719719
*/
720720
public static function deprecationCheck(){
721+
// The check and message that the user is still using the deprecated version
721722
$deprecations = [
722723
'ms_teams_deprecated' => array(
723-
'check' => Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'),
724+
'check' => !Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows'),
724725
'message' => 'The Microsoft Teams webhook URL being used will be deprecated Jan 31st, 2025. <a class="btn btn-primary" href="' . route('settings.slack.index') . '">Change your webhook URL</a>'),
725726
];
726727

727-
return $deprecations;
728+
// if item of concern is being used and its being used with the deprecated values return the notification array.
729+
if(Setting::getSettings()->webhook_selected === 'microsoft' && $deprecations['ms_teams_deprecated']['check']) {
730+
return $deprecations;
731+
}
732+
return [];
728733
}
729734

730735
/**

app/Livewire/SlackSettingsForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ public function mount() {
8181
$this->webhook_channel = $this->setting->webhook_channel;
8282
$this->webhook_botname = $this->setting->webhook_botname;
8383
$this->webhook_options = $this->setting->webhook_selected;
84-
$this->teams_webhook_deprecated = Str::contains($this->webhook_endpoint, 'workflows');
84+
$this->teams_webhook_deprecated = !Str::contains($this->webhook_endpoint, 'workflows');
8585
if($this->webhook_selected === 'microsoft' || $this->webhook_selected === 'google'){
8686
$this->webhook_channel = '#NA';
8787
}
8888

8989
if($this->setting->webhook_endpoint != null && $this->setting->webhook_channel != null){
9090
$this->isDisabled= '';
9191
}
92-
if($this->webhook_selected === 'microsoft' && !$this->teams_webhook_deprecated) {
92+
if($this->webhook_selected === 'microsoft' && $this->teams_webhook_deprecated) {
9393
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 <a href="https://support.microsoft.com/en-us/office/create-incoming-webhooks-with-workflows-for-microsoft-teams-8ae491c7-0394-4861-ba59-055e33f75498" target="_blank"> here.</a>');
9494
}
9595
}

app/Notifications/CheckinAccessoryNotification.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Notifications\Messages\MailMessage;
1010
use Illuminate\Notifications\Messages\SlackMessage;
1111
use Illuminate\Notifications\Notification;
12+
use Illuminate\Support\Str;
1213
use NotificationChannels\GoogleChat\Card;
1314
use NotificationChannels\GoogleChat\GoogleChatChannel;
1415
use NotificationChannels\GoogleChat\GoogleChatMessage;
@@ -103,6 +104,7 @@ public function toMicrosoftTeams()
103104
$admin = $this->admin;
104105
$item = $this->item;
105106
$note = $this->note;
107+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {}
106108

107109
$message = trans('mail.Accessory_Checkin_Notification');
108110
$details = [

app/Notifications/CheckinAssetNotification.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Illuminate\Notifications\Messages\MailMessage;
1111
use Illuminate\Notifications\Messages\SlackMessage;
1212
use Illuminate\Notifications\Notification;
13+
use Illuminate\Support\Str;
1314
use NotificationChannels\GoogleChat\Card;
1415
use NotificationChannels\GoogleChat\GoogleChatChannel;
1516
use NotificationChannels\GoogleChat\GoogleChatMessage;
@@ -106,6 +107,20 @@ public function toMicrosoftTeams()
106107
$item = $this->item;
107108
$note = $this->note;
108109

110+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
111+
return MicrosoftTeamsMessage::create()
112+
->to($this->settings->webhook_endpoint)
113+
->type('success')
114+
->title(trans('mail.Asset_Checkin_Notification'))
115+
->addStartGroupToSection('activityText')
116+
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
117+
->fact(trans('mail.checked_into'), $item->location->name ? $item->location->name : '')
118+
->fact(trans('mail.Asset_Checkin_Notification') . " by ", $admin->present()->fullName())
119+
->fact(trans('admin/hardware/form.status'), $item->assetstatus->name)
120+
->fact(trans('mail.notes'), $note ?: '');
121+
}
122+
123+
109124
$message = trans('mail.Asset_Checkin_Notification');
110125
$details = [
111126
trans('mail.asset') => htmlspecialchars_decode($item->present()->name),

app/Notifications/CheckinLicenseSeatNotification.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Notifications\Messages\MailMessage;
1010
use Illuminate\Notifications\Messages\SlackMessage;
1111
use Illuminate\Notifications\Notification;
12+
use Illuminate\Support\Str;
1213
use NotificationChannels\GoogleChat\Card;
1314
use NotificationChannels\GoogleChat\GoogleChatChannel;
1415
use NotificationChannels\GoogleChat\GoogleChatMessage;
@@ -109,6 +110,19 @@ public function toMicrosoftTeams()
109110
$admin = $this->admin;
110111
$item = $this->item;
111112
$note = $this->note;
113+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
114+
return MicrosoftTeamsMessage::create()
115+
->to($this->settings->webhook_endpoint)
116+
->type('success')
117+
->addStartGroupToSection('activityTitle')
118+
->title(trans('mail.License_Checkin_Notification'))
119+
->addStartGroupToSection('activityText')
120+
->fact(htmlspecialchars_decode($item->present()->name), '', 'header')
121+
->fact(trans('mail.License_Checkin_Notification')." by ", $admin->present()->fullName() ?: 'CLI tool')
122+
->fact(trans('mail.checkedin_from'), $target->present()->fullName())
123+
->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count())
124+
->fact(trans('mail.notes'), $note ?: '');
125+
}
112126

113127
$message = trans('mail.License_Checkin_Notification');
114128
$details = [

app/Notifications/CheckoutAccessoryNotification.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Notifications\Messages\MailMessage;
1010
use Illuminate\Notifications\Messages\SlackMessage;
1111
use Illuminate\Notifications\Notification;
12+
use Illuminate\Support\Str;
1213
use NotificationChannels\GoogleChat\Card;
1314
use NotificationChannels\GoogleChat\GoogleChatChannel;
1415
use NotificationChannels\GoogleChat\GoogleChatMessage;
@@ -120,6 +121,22 @@ public function toMicrosoftTeams()
120121
$item = $this->item;
121122
$note = $this->note;
122123

124+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
125+
return MicrosoftTeamsMessage::create()
126+
->to($this->settings->webhook_endpoint)
127+
->type('success')
128+
->addStartGroupToSection('activityTitle')
129+
->title(trans('mail.Accessory_Checkout_Notification'))
130+
->addStartGroupToSection('activityText')
131+
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
132+
->fact(trans('mail.assigned_to'), $target->present()->name)
133+
->fact(trans('general.qty'), $this->checkout_qty)
134+
->fact(trans('mail.checkedout_from'), $item->location->name ? $item->location->name : '')
135+
->fact(trans('mail.Accessory_Checkout_Notification') . " by ", $admin->present()->fullName())
136+
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
137+
->fact(trans('mail.notes'), $note ?: '');
138+
}
139+
123140
$message = trans('mail.Accessory_Checkout_Notification');
124141
$details = [
125142
trans('mail.assigned_to') => $target->present()->name,

app/Notifications/CheckoutAssetNotification.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Illuminate\Notifications\Messages\MailMessage;
1212
use Illuminate\Notifications\Messages\SlackMessage;
1313
use Illuminate\Notifications\Notification;
14+
use Illuminate\Support\Str;
1415
use NotificationChannels\GoogleChat\Card;
1516
use NotificationChannels\GoogleChat\Enums\Icon;
1617
use NotificationChannels\GoogleChat\Enums\ImageStyle;
@@ -148,6 +149,18 @@ public function toMicrosoftTeams() : array
148149
$item = $this->item;
149150
$note = $this->note;
150151

152+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
153+
return MicrosoftTeamsMessage::create()
154+
->to($this->settings->webhook_endpoint)
155+
->type('success')
156+
->title(trans('mail.Asset_Checkout_Notification'))
157+
->addStartGroupToSection('activityText')
158+
->fact(trans('mail.assigned_to'), $target->present()->name)
159+
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
160+
->fact(trans('mail.Asset_Checkout_Notification') . " by ", $admin->present()->fullName())
161+
->fact(trans('mail.notes'), $note ?: '');
162+
}
163+
151164
$message = trans('mail.Asset_Checkout_Notification');
152165
$details = [
153166
trans('mail.assigned_to') => $target->present()->name,

app/Notifications/CheckoutConsumableNotification.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Notifications\Messages\MailMessage;
1010
use Illuminate\Notifications\Messages\SlackMessage;
1111
use Illuminate\Notifications\Notification;
12+
use Illuminate\Support\Str;
1213
use NotificationChannels\GoogleChat\Card;
1314
use NotificationChannels\GoogleChat\GoogleChatChannel;
1415
use NotificationChannels\GoogleChat\GoogleChatMessage;
@@ -127,6 +128,20 @@ public function toMicrosoftTeams()
127128
$item = $this->item;
128129
$note = $this->note;
129130

131+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
132+
return MicrosoftTeamsMessage::create()
133+
->to($this->settings->webhook_endpoint)
134+
->type('success')
135+
->addStartGroupToSection('activityTitle')
136+
->title(trans('mail.Consumable_checkout_notification'))
137+
->addStartGroupToSection('activityText')
138+
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
139+
->fact(trans('mail.Consumable_checkout_notification')." by ", $admin->present()->fullName())
140+
->fact(trans('mail.assigned_to'), $target->present()->fullName())
141+
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
142+
->fact(trans('mail.notes'), $note ?: '');
143+
}
144+
130145
$message = trans('mail.Consumable_checkout_notification');
131146
$details = [
132147
trans('mail.assigned_to') => $target->present()->fullName(),

app/Notifications/CheckoutLicenseSeatNotification.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Notifications\Messages\MailMessage;
1010
use Illuminate\Notifications\Messages\SlackMessage;
1111
use Illuminate\Notifications\Notification;
12+
use Illuminate\Support\Str;
1213
use NotificationChannels\GoogleChat\Card;
1314
use NotificationChannels\GoogleChat\GoogleChatChannel;
1415
use NotificationChannels\GoogleChat\GoogleChatMessage;
@@ -125,6 +126,20 @@ public function toMicrosoftTeams()
125126
$item = $this->item;
126127
$note = $this->note;
127128

129+
if(!Str::contains(Setting::getSettings()->webhook_endpoint, 'workflows')) {
130+
return MicrosoftTeamsMessage::create()
131+
->to($this->settings->webhook_endpoint)
132+
->type('success')
133+
->addStartGroupToSection('activityTitle')
134+
->title(trans('mail.License_Checkout_Notification'))
135+
->addStartGroupToSection('activityText')
136+
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
137+
->fact(trans('mail.License_Checkout_Notification')." by ", $admin->present()->fullName())
138+
->fact(trans('mail.assigned_to'), $target->present()->fullName())
139+
->fact(trans('admin/consumables/general.remaining'), $item->availCount()->count())
140+
->fact(trans('mail.notes'), $note ?: '');
141+
}
142+
128143
$message = trans('mail.License_Checkout_Notification');
129144
$details = [
130145
trans('mail.assigned_to') => $target->present()->fullName(),

resources/views/layouts/default.blade.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,12 @@
279279
@endif
280280
</a>
281281
<ul class="dropdown-menu">
282-
@if($snipeSettings->webhook_selected === 'microsoft' && $deprecations['ms_teams_deprecated']['check'])
283-
<li class="header alert-warning">{!! $deprecations['ms_teams_deprecated']['message'] !!}</li>
282+
@if($deprecations)
283+
@foreach ($deprecations as $key => $deprecation)
284+
@if ($deprecation['check'])
285+
<li class="header alert-warning">{!! $deprecation['message'] !!}</li>
286+
@endif
287+
@endforeach
284288
@endif
285289
<li class="header">{{ trans_choice('general.quantity_minimum', count($alert_items)) }}</li>
286290
<li>

0 commit comments

Comments
 (0)