added a location check, to prevent notif blowing up

This commit is contained in:
Godfrey M 2024-01-23 13:05:39 -08:00
parent b797795d37
commit f270672a3d
5 changed files with 24 additions and 17 deletions

View file

@ -225,9 +225,10 @@ class CheckoutableListener
break; break;
case LicenseSeat::class: case LicenseSeat::class:
$notificationClass = CheckoutLicenseSeatNotification::class; $notificationClass = CheckoutLicenseSeatNotification::class;
break; break;
} }
return new $notificationClass($event->checkoutable, $event->checkedOutTo, $event->checkedOutBy, $acceptance, $event->note); return new $notificationClass($event->checkoutable, $event->checkedOutTo, $event->checkedOutBy, $acceptance, $event->note);
} }

View file

@ -126,7 +126,7 @@ class CheckinAccessoryNotification extends Notification
->title("Accessory Checked In") ->title("Accessory Checked In")
->addStartGroupToSection('activityText') ->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle') ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact('Checked into ', $item->location->name) ->fact('Checked into ', $item->location->name ? $item->location->name : '')
->fact(trans('mail.Accessory_Checkin_Notification')." by ", $admin->present()->fullName()) ->fact(trans('mail.Accessory_Checkin_Notification')." by ", $admin->present()->fullName())
->fact('Number Remaining', $item->numRemaining()) ->fact('Number Remaining', $item->numRemaining())
->fact('Notes', $note ?: 'No notes'); ->fact('Notes', $note ?: 'No notes');

View file

@ -99,11 +99,10 @@ class CheckinAssetNotification extends Notification
return MicrosoftTeamsMessage::create() return MicrosoftTeamsMessage::create()
->to($this->settings->webhook_endpoint) ->to($this->settings->webhook_endpoint)
->type('success') ->type('success')
->addStartGroupToSection('activityTitle')
->title("Asset Checked in") ->title("Asset Checked in")
->addStartGroupToSection('activityText') ->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'header') ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
->fact('Checked into ', $item->location->name) ->fact('Checked into ', $item->location->name ? $item->location->name : '')
->fact(trans('mail.Asset_Checkin_Notification')." by ", $admin->present()->fullName()) ->fact(trans('mail.Asset_Checkin_Notification')." by ", $admin->present()->fullName())
->fact('Asset Status', $item->assetstatus->name) ->fact('Asset Status', $item->assetstatus->name)
->fact('Notes', $note ?: 'No notes'); ->fact('Notes', $note ?: 'No notes');

View file

@ -116,7 +116,7 @@ class CheckoutAccessoryNotification extends Notification
->title("Accessory Checked Out") ->title("Accessory Checked Out")
->addStartGroupToSection('activityText') ->addStartGroupToSection('activityText')
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle') ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
->fact('Checked out from ', $item->location->name) ->fact('Checked out from ', $item->location->name ? $item->location->name : '')
->fact(trans('mail.Accessory_Checkout_Notification')." by ", $admin->present()->fullName()) ->fact(trans('mail.Accessory_Checkout_Notification')." by ", $admin->present()->fullName())
->fact('Number Remaining', $item->numRemaining()) ->fact('Number Remaining', $item->numRemaining())
->fact('Notes', $note ?: 'No notes'); ->fact('Notes', $note ?: 'No notes');

View file

@ -6,6 +6,7 @@ use App\Helpers\Helper;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Setting; use App\Models\Setting;
use App\Models\User; use App\Models\User;
use Exception;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage; use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\SlackMessage; use Illuminate\Notifications\Messages\SlackMessage;
@ -129,17 +130,23 @@ class CheckoutAssetNotification extends Notification
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
return MicrosoftTeamsMessage::create() try {
->to($this->settings->webhook_endpoint)
->type('success') return MicrosoftTeamsMessage::create()
->addStartGroupToSection('activityTitle') ->to($this->settings->webhook_endpoint)
->title("Asset Checked Out") ->type('success')
->addStartGroupToSection('activityText') ->title("Asset Checked Out")
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle') ->addStartGroupToSection('activityText')
->fact('Checked out from ', $item->location->name) ->fact(htmlspecialchars_decode($item->present()->name), '', 'activityText')
->fact(trans('mail.Asset_Checkout_Notification')." by ", $admin->present()->fullName()) ->fact('Checked out from ', $item->location ? $item->location->name : '')
->fact('Asset Status', $item->assetstatus->name) ->fact(trans('mail.Asset_Checkout_Notification') . " by ", $admin->present()->fullName())
->fact('Notes', $note ?: 'No notes'); ->fact('Asset Status', $item->assetstatus->name)
->fact('Notes', $note ?: 'No notes');
}
catch(Exception $e) {
dd($e);
}
} }
/** /**