mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-13 15:01:02 -08:00
adds licenses ms notifications
This commit is contained in:
parent
5a46ef5d5b
commit
e969f8808c
|
@ -112,11 +112,15 @@ class CheckoutableListener
|
||||||
$this->getCheckinNotification($event)
|
$this->getCheckinNotification($event)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
//slack doesn't include the url in its messaging format so this is needed to hit the endpoint
|
||||||
|
if(Setting::getSettings()->webhook_selected =='slack') {
|
||||||
|
|
||||||
if ($this->shouldSendWebhookNotification()) {
|
if ($this->shouldSendWebhookNotification()) {
|
||||||
Notification::route('slack', Setting::getSettings()->webhook_endpoint)
|
Notification::route('slack', Setting::getSettings()->webhook_endpoint)
|
||||||
->notify($this->getCheckinNotification($event));
|
->notify($this->getCheckinNotification($event));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} catch (ClientException $e) {
|
} catch (ClientException $e) {
|
||||||
Log::debug("Exception caught during checkout notification: " . $e->getMessage());
|
Log::debug("Exception caught during checkout notification: " . $e->getMessage());
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
|
|
@ -123,10 +123,10 @@ class CheckinAccessoryNotification extends Notification
|
||||||
->to($this->settings->webhook_endpoint)
|
->to($this->settings->webhook_endpoint)
|
||||||
->type('success')
|
->type('success')
|
||||||
->addStartGroupToSection('activityTitle')
|
->addStartGroupToSection('activityTitle')
|
||||||
->title("Accessory Checked Out")
|
->title("Accessory Checked In")
|
||||||
->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 into ', $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');
|
||||||
|
|
|
@ -9,6 +9,8 @@ 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\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||||
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||||
|
|
||||||
class CheckinLicenseSeatNotification extends Notification
|
class CheckinLicenseSeatNotification extends Notification
|
||||||
{
|
{
|
||||||
|
@ -41,6 +43,11 @@ class CheckinLicenseSeatNotification extends Notification
|
||||||
{
|
{
|
||||||
$notifyBy = [];
|
$notifyBy = [];
|
||||||
|
|
||||||
|
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||||
|
|
||||||
|
$notifyBy[] = MicrosoftTeamsChannel::class;
|
||||||
|
}
|
||||||
|
|
||||||
if (Setting::getSettings()->webhook_endpoint != '') {
|
if (Setting::getSettings()->webhook_endpoint != '') {
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
@ -87,6 +94,25 @@ class CheckinLicenseSeatNotification extends Notification
|
||||||
->content($note);
|
->content($note);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public function toMicrosoftTeams()
|
||||||
|
{
|
||||||
|
$target = $this->target;
|
||||||
|
$admin = $this->admin;
|
||||||
|
$item = $this->item;
|
||||||
|
$note = $this->note;
|
||||||
|
|
||||||
|
return MicrosoftTeamsMessage::create()
|
||||||
|
->to($this->settings->webhook_endpoint)
|
||||||
|
->type('success')
|
||||||
|
->addStartGroupToSection('activityTitle')
|
||||||
|
->title("License Checked in")
|
||||||
|
->addStartGroupToSection('activityText')
|
||||||
|
->fact(htmlspecialchars_decode($item->present()->name), '', 'header')
|
||||||
|
->fact(trans('mail.License_Checkin_Notification')." by ", $admin->present()->fullName() ?: 'ClI tool')
|
||||||
|
->fact('Checked in from', $target->present()->fullName())
|
||||||
|
->fact('Seats Remaining', $item->availCount()->count())
|
||||||
|
->fact('Notes', $note ?: 'No notes');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mail representation of the notification.
|
* Get the mail representation of the notification.
|
||||||
|
|
|
@ -26,7 +26,6 @@ class CheckoutAccessoryNotification extends Notification
|
||||||
$this->note = $note;
|
$this->note = $note;
|
||||||
$this->target = $checkedOutTo;
|
$this->target = $checkedOutTo;
|
||||||
$this->acceptance = $acceptance;
|
$this->acceptance = $acceptance;
|
||||||
|
|
||||||
$this->settings = Setting::getSettings();
|
$this->settings = Setting::getSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ 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\MicrosoftTeams\MicrosoftTeamsChannel;
|
||||||
|
use NotificationChannels\MicrosoftTeams\MicrosoftTeamsMessage;
|
||||||
|
|
||||||
class CheckoutLicenseSeatNotification extends Notification
|
class CheckoutLicenseSeatNotification extends Notification
|
||||||
{
|
{
|
||||||
|
@ -41,8 +43,14 @@ class CheckoutLicenseSeatNotification extends Notification
|
||||||
*/
|
*/
|
||||||
public function via()
|
public function via()
|
||||||
{
|
{
|
||||||
|
|
||||||
$notifyBy = [];
|
$notifyBy = [];
|
||||||
|
|
||||||
|
if (Setting::getSettings()->webhook_selected == 'microsoft'){
|
||||||
|
|
||||||
|
$notifyBy[] = MicrosoftTeamsChannel::class;
|
||||||
|
}
|
||||||
|
|
||||||
if (Setting::getSettings()->webhook_endpoint != '') {
|
if (Setting::getSettings()->webhook_endpoint != '') {
|
||||||
$notifyBy[] = 'slack';
|
$notifyBy[] = 'slack';
|
||||||
}
|
}
|
||||||
|
@ -102,6 +110,25 @@ class CheckoutLicenseSeatNotification extends Notification
|
||||||
->content($note);
|
->content($note);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public function toMicrosoftTeams()
|
||||||
|
{
|
||||||
|
$target = $this->target;
|
||||||
|
$admin = $this->admin;
|
||||||
|
$item = $this->item;
|
||||||
|
$note = $this->note;
|
||||||
|
|
||||||
|
return MicrosoftTeamsMessage::create()
|
||||||
|
->to($this->settings->webhook_endpoint)
|
||||||
|
->type('success')
|
||||||
|
->addStartGroupToSection('activityTitle')
|
||||||
|
->title("License Checked Out")
|
||||||
|
->addStartGroupToSection('activityText')
|
||||||
|
->fact(htmlspecialchars_decode($item->present()->name), '', 'activityTitle')
|
||||||
|
->fact(trans('mail.License_Checkout_Notification')." by ", $admin->present()->fullName())
|
||||||
|
->fact('Checked out to', $target->present()->fullName())
|
||||||
|
->fact('Seats Remaining', $item->availCount()->count())
|
||||||
|
->fact('Notes', $note ?: 'No notes');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mail representation of the notification.
|
* Get the mail representation of the notification.
|
||||||
|
|
|
@ -21,6 +21,7 @@ return [
|
||||||
'Item_Request_Canceled' => 'Item Request Canceled',
|
'Item_Request_Canceled' => 'Item Request Canceled',
|
||||||
'Item_Requested' => 'Item Requested',
|
'Item_Requested' => 'Item Requested',
|
||||||
'License_Checkin_Notification' => 'License checked in',
|
'License_Checkin_Notification' => 'License checked in',
|
||||||
|
'License_Checkout_Notification' => 'License checked out',
|
||||||
'Low_Inventory_Report' => 'Low Inventory Report',
|
'Low_Inventory_Report' => 'Low Inventory Report',
|
||||||
'a_user_canceled' => 'A user has canceled an item request on the website',
|
'a_user_canceled' => 'A user has canceled an item request on the website',
|
||||||
'a_user_requested' => 'A user has requested an item on the website',
|
'a_user_requested' => 'A user has requested an item on the website',
|
||||||
|
|
Loading…
Reference in a new issue