Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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. <a class="btn btn-primary" href="' . route('settings.slack.index') . '">Change webhook endpoint</a>'),
'message' => 'The Microsoft Teams webhook URL being used was deprecated Jan 31st, 2025. <a class="btn btn-primary" href="' . route('settings.slack.index') . '">Change webhook endpoint</a>'),
];

// if item of concern is being used and its being used with the deprecated values return the notification array.
Expand Down
15 changes: 10 additions & 5 deletions app/Listeners/CheckoutableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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');
}
}
20 changes: 1 addition & 19 deletions app/Livewire/SlackSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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>');
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 <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>');
}
}
public function updated($field) {
Expand Down Expand Up @@ -247,31 +247,13 @@ 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);

$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]));
Expand Down
18 changes: 0 additions & 18 deletions app/Notifications/CheckinAccessoryNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 = [
Expand Down
18 changes: 0 additions & 18 deletions app/Notifications/CheckinAssetNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
17 changes: 0 additions & 17 deletions app/Notifications/CheckinLicenseSeatNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [
Expand Down
21 changes: 0 additions & 21 deletions app/Notifications/CheckoutAccessoryNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 0 additions & 18 deletions app/Notifications/CheckoutAssetNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 0 additions & 18 deletions app/Notifications/CheckoutLicenseSeatNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
Loading