mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
adds google notifs to accessories check in and out
This commit is contained in:
parent
87bce0c097
commit
e074ca0bf9
|
@ -9,6 +9,11 @@ use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use NotificationChannels\GoogleChat\Card;
|
||||||
|
use NotificationChannels\GoogleChat\GoogleChatChannel;
|
||||||
|
use NotificationChannels\GoogleChat\GoogleChatMessage;
|
||||||
|
use NotificationChannels\GoogleChat\Section;
|
||||||
|
use NotificationChannels\GoogleChat\Widgets\KeyValue;
|
||||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||||
|
|
||||||
|
@ -38,6 +43,10 @@ class CheckinAccessoryNotification extends Notification
|
||||||
public function via()
|
public function via()
|
||||||
{
|
{
|
||||||
$notifyBy = [];
|
$notifyBy = [];
|
||||||
|
if (Setting::getSettings()->webhook_selected == 'google'){
|
||||||
|
|
||||||
|
$notifyBy[] = GoogleChatChannel::class;
|
||||||
|
}
|
||||||
|
|
||||||
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||||
|
|
||||||
|
@ -132,6 +141,33 @@ class CheckinAccessoryNotification extends Notification
|
||||||
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
|
->fact(trans('admin/consumables/general.remaining'), $item->numRemaining())
|
||||||
->fact(trans('mail.notes'), $note ?: '');
|
->fact(trans('mail.notes'), $note ?: '');
|
||||||
}
|
}
|
||||||
|
public function toGoogleChat()
|
||||||
|
{
|
||||||
|
$item = $this->item;
|
||||||
|
$note = $this->note;
|
||||||
|
|
||||||
|
return GoogleChatMessage::create()
|
||||||
|
->to($this->settings->webhook_endpoint)
|
||||||
|
->card(
|
||||||
|
Card::create()
|
||||||
|
->header(
|
||||||
|
'<strong>'.trans('mail.Accessory_Checkin_Notification').'</strong>' ?: '',
|
||||||
|
htmlspecialchars_decode($item->present()->name) ?: '',
|
||||||
|
)
|
||||||
|
->section(
|
||||||
|
Section::create(
|
||||||
|
KeyValue::create(
|
||||||
|
trans('mail.checked_into').': '.$item->location->name ? $item->location->name : '',
|
||||||
|
trans('admin/consumables/general.remaining').': '.$item->numRemaining(),
|
||||||
|
trans('admin/hardware/form.notes').": ".$note ?: '',
|
||||||
|
|
||||||
|
)
|
||||||
|
->onClick(route('accessories.show', $item->id))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mail representation of the notification.
|
* Get the mail representation of the notification.
|
||||||
|
|
|
@ -136,7 +136,7 @@ class CheckinAssetNotification extends Notification
|
||||||
KeyValue::create(
|
KeyValue::create(
|
||||||
trans('mail.checked_into') ?: '',
|
trans('mail.checked_into') ?: '',
|
||||||
$item->location->name ? $item->location->name : '',
|
$item->location->name ? $item->location->name : '',
|
||||||
trans('admin/hardware/form.status').":".$item->assetstatus->name,
|
trans('admin/hardware/form.status').": ".$item->assetstatus->name,
|
||||||
)
|
)
|
||||||
->onClick(route('hardware.show', $item->id))
|
->onClick(route('hardware.show', $item->id))
|
||||||
)
|
)
|
||||||
|
|
|
@ -9,6 +9,11 @@ use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Messages\MailMessage;
|
use Illuminate\Notifications\Messages\MailMessage;
|
||||||
use Illuminate\Notifications\Messages\SlackMessage;
|
use Illuminate\Notifications\Messages\SlackMessage;
|
||||||
use Illuminate\Notifications\Notification;
|
use Illuminate\Notifications\Notification;
|
||||||
|
use NotificationChannels\GoogleChat\Card;
|
||||||
|
use NotificationChannels\GoogleChat\GoogleChatChannel;
|
||||||
|
use NotificationChannels\GoogleChat\GoogleChatMessage;
|
||||||
|
use NotificationChannels\GoogleChat\Section;
|
||||||
|
use NotificationChannels\GoogleChat\Widgets\KeyValue;
|
||||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||||
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||||
|
|
||||||
|
@ -37,6 +42,10 @@ class CheckoutAccessoryNotification extends Notification
|
||||||
public function via()
|
public function via()
|
||||||
{
|
{
|
||||||
$notifyBy = [];
|
$notifyBy = [];
|
||||||
|
if (Setting::getSettings()->webhook_selected == 'google'){
|
||||||
|
|
||||||
|
$notifyBy[] = GoogleChatChannel::class;
|
||||||
|
}
|
||||||
|
|
||||||
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||||
|
|
||||||
|
@ -123,6 +132,34 @@ class CheckoutAccessoryNotification extends Notification
|
||||||
->fact(trans('mail.notes'), $note ?: '');
|
->fact(trans('mail.notes'), $note ?: '');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public function toGoogleChat()
|
||||||
|
{
|
||||||
|
$target = $this->target;
|
||||||
|
$item = $this->item;
|
||||||
|
$note = $this->note;
|
||||||
|
|
||||||
|
return GoogleChatMessage::create()
|
||||||
|
->to($this->settings->webhook_endpoint)
|
||||||
|
->card(
|
||||||
|
Card::create()
|
||||||
|
->header(
|
||||||
|
'<strong>'.trans('mail.Accessory_Checkout_Notification').'</strong>' ?: '',
|
||||||
|
htmlspecialchars_decode($item->present()->name) ?: '',
|
||||||
|
)
|
||||||
|
->section(
|
||||||
|
Section::create(
|
||||||
|
KeyValue::create(
|
||||||
|
trans('mail.assigned_to') ?: '',
|
||||||
|
$target->present()->name ?: '',
|
||||||
|
trans('admin/consumables/general.remaining').": ". $item->numRemaining(),
|
||||||
|
)
|
||||||
|
->onClick(route('users.show', $target->id))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mail representation of the notification.
|
* Get the mail representation of the notification.
|
||||||
|
|
Loading…
Reference in a new issue