mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
adds check in and checkout message for assets
This commit is contained in:
parent
18da80e6de
commit
e27ff13377
|
@ -49,16 +49,16 @@ class CheckoutableListener
|
|||
|
||||
// Send email notifications
|
||||
try {
|
||||
// foreach ($notifiables as $notifiable) {
|
||||
// if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
// if (! $event->checkedOutTo->locale){
|
||||
// Notification::locale(Setting::getSettings()->locale)->send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
||||
// }
|
||||
// else {
|
||||
// Notification::send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
foreach ($notifiables as $notifiable) {
|
||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if (! $event->checkedOutTo->locale){
|
||||
Notification::locale(Setting::getSettings()->locale)->send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
||||
}
|
||||
else {
|
||||
Notification::send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Send Webhook notification
|
||||
if ($this->shouldSendWebhookNotification()) {
|
||||
|
@ -116,23 +116,30 @@ class CheckoutableListener
|
|||
$notifiables = $this->getNotifiables($event);
|
||||
// Send email notifications
|
||||
try {
|
||||
foreach ($notifiables as $notifiable) {
|
||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if (! $event->checkedOutTo->locale){
|
||||
Notification::locale(Setting::getSettings()->locale)->send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
||||
}
|
||||
else {
|
||||
Notification::send($notifiable, $this->getCheckinNotification($event));
|
||||
}
|
||||
}
|
||||
}
|
||||
// foreach ($notifiables as $notifiable) {
|
||||
// if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
// if (! $event->checkedOutTo->locale){
|
||||
// Notification::locale(Setting::getSettings()->locale)->send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
||||
// }
|
||||
// else {
|
||||
// Notification::send($notifiable, $this->getCheckinNotification($event));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Send Webhook notification
|
||||
if ($this->shouldSendWebhookNotification()) {
|
||||
// Slack doesn't include the URL in its messaging format, so this is needed to hit the endpoint
|
||||
if (Setting::getSettings()->webhook_selected === 'slack' || Setting::getSettings()->webhook_selected === 'general') {
|
||||
Notification::route('slack', Setting::getSettings()->webhook_endpoint)
|
||||
->notify($this->getCheckinNotification($event));
|
||||
} else {
|
||||
} // Handling Microsoft Teams notification
|
||||
else if (Setting::getSettings()->webhook_selected === 'microsoft') {
|
||||
|
||||
$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
|
||||
}
|
||||
else {
|
||||
Notification::route(Setting::getSettings()->webhook_selected, Setting::getSettings()->webhook_endpoint)
|
||||
->notify($this->getCheckinNotification($event));
|
||||
}
|
||||
|
|
|
@ -106,16 +106,16 @@ class CheckinAssetNotification extends Notification
|
|||
$item = $this->item;
|
||||
$note = $this->note;
|
||||
|
||||
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->name ? $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),
|
||||
trans('mail.checked_into') => $item->location->name ? $item->location->name : '',
|
||||
trans('mail.Asset_Checkin_Notification')." by " => $admin->present()->fullName(),
|
||||
trans('admin/hardware/form.status') => $item->assetstatus->name,
|
||||
trans('mail.notes') => $note ?: '',
|
||||
];
|
||||
|
||||
return array($message, $details);
|
||||
}
|
||||
public function toGoogleChat()
|
||||
{
|
||||
|
|
|
@ -141,33 +141,21 @@ class CheckoutAssetNotification extends Notification
|
|||
->content($note);
|
||||
});
|
||||
}
|
||||
public function toMicrosoftTeams()
|
||||
public function toMicrosoftTeams() : array
|
||||
{
|
||||
$target = $this->target;
|
||||
$admin = $this->admin;
|
||||
$item = $this->item;
|
||||
$note = $this->note;
|
||||
|
||||
$notification = new TeamsNotification($this->settings->webhook_channel);
|
||||
$message = trans('mail.Asset_Checkout_Notification');
|
||||
$details = [
|
||||
trans('mail.assigned_to') => $target->present()->name,
|
||||
htmlspecialchars_decode($item->present()->name) => '',
|
||||
trans('mail.asset') => htmlspecialchars_decode($item->present()->name),
|
||||
trans('mail.Asset_Checkout_Notification'). ' by' => $admin->present()->fullName(),
|
||||
trans('mail.notes') => $note ?: '',
|
||||
];
|
||||
return array($message, $details);
|
||||
// return MicrosoftTeamsMessage::create()
|
||||
// ->to($this->settings->webhook_endpoint)
|
||||
// ->type('success')
|
||||
// ->title()
|
||||
// ->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 ?: '');
|
||||
|
||||
|
||||
}
|
||||
public function toGoogleChat()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue