Merge pull request #12717 from marcusmoore/fixes/update-slack-property-names

Fixes calls to changed webhook properties names
This commit is contained in:
snipe 2023-03-23 10:55:02 -07:00 committed by GitHub
commit fc3672c119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 40 additions and 45 deletions

View file

@ -83,9 +83,9 @@ class Setting extends Model
'email_domain', 'email_domain',
'email_format', 'email_format',
'username_format', 'username_format',
'slack_endpoint', 'webhook_endpoint',
'slack_channel', 'webhook_channel',
'slack_botname', 'webhook_botname',
]; ];
/** /**
@ -265,7 +265,7 @@ class Setting extends Model
{ {
// At this point the endpoint is the same for everything. // At this point the endpoint is the same for everything.
// In the future this may want to be adapted for individual notifications. // In the future this may want to be adapted for individual notifications.
return self::getSettings()->slack_endpoint; return self::getSettings()->webhook_endpoint;
} }
/** /**

View file

@ -272,7 +272,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
{ {
// At this point the endpoint is the same for everything. // At this point the endpoint is the same for everything.
// In the future this may want to be adapted for individual notifications. // In the future this may want to be adapted for individual notifications.
$this->endpoint = \App\Models\Setting::getSettings()->slack_endpoint; $this->endpoint = \App\Models\Setting::getSettings()->webhook_endpoint;
return $this->endpoint; return $this->endpoint;
} }

View file

@ -34,7 +34,7 @@ class AuditNotification extends Notification
public function via() public function via()
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint) { if (Setting::getSettings()->webhook_endpoint) {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }

View file

@ -39,11 +39,7 @@ class CheckinAccessoryNotification extends Notification
\Log::debug('via called'); \Log::debug('via called');
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint) { if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack';
}
if (Setting::getSettings()->slack_endpoint != '') {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -95,7 +91,7 @@ class CheckinAccessoryNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',

View file

@ -43,9 +43,8 @@ class CheckinAssetNotification extends Notification
public function via() public function via()
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->webhook_endpoint != '') {
if (Setting::getSettings()->slack_endpoint != '') { \Log::debug('use webhook');
\Log::debug('use slack');
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -65,7 +64,7 @@ class CheckinAssetNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname != '') ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname != '') ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>', trans('general.administrator') => '<'.$admin->present()->viewUrl().'|'.$admin->present()->fullName().'>',

View file

@ -41,7 +41,7 @@ class CheckinLicenseSeatNotification extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint != '') { if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -62,7 +62,7 @@ class CheckinLicenseSeatNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
if ($admin) { if ($admin) {
$fields = [ $fields = [

View file

@ -37,7 +37,7 @@ class CheckoutAccessoryNotification extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint != '') { if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -78,7 +78,7 @@ class CheckoutAccessoryNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',

View file

@ -53,8 +53,8 @@ class CheckoutAssetNotification extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if ((Setting::getSettings()) && (Setting::getSettings()->slack_endpoint != '')) { if ((Setting::getSettings()) && (Setting::getSettings()->webhook_endpoint != '')) {
\Log::debug('use slack'); \Log::debug('use webhook');
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -95,7 +95,7 @@ class CheckoutAssetNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',

View file

@ -43,7 +43,7 @@ class CheckoutConsumableNotification extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint != '') { if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -84,7 +84,7 @@ class CheckoutConsumableNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',

View file

@ -43,7 +43,7 @@ class CheckoutLicenseSeatNotification extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint != '') { if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -84,7 +84,7 @@ class CheckoutLicenseSeatNotification extends Notification
$admin = $this->admin; $admin = $this->admin;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>', 'To' => '<'.$target->present()->viewUrl().'|'.$target->present()->fullName().'>',

View file

@ -57,8 +57,8 @@ class RequestAssetCancelation extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint != '') { if (Setting::getSettings()->webhook_endpoint != '') {
\Log::debug('use slack'); \Log::debug('use webhook');
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -73,7 +73,7 @@ class RequestAssetCancelation extends Notification
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$qty = $this->item_quantity; $qty = $this->item_quantity;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'QTY' => $qty, 'QTY' => $qty,

View file

@ -58,7 +58,7 @@ class RequestAssetNotification extends Notification
{ {
$notifyBy = []; $notifyBy = [];
if (Setting::getSettings()->slack_endpoint != '') { if (Setting::getSettings()->webhook_endpoint != '') {
$notifyBy[] = 'slack'; $notifyBy[] = 'slack';
} }
@ -73,7 +73,7 @@ class RequestAssetNotification extends Notification
$qty = $this->item_quantity; $qty = $this->item_quantity;
$item = $this->item; $item = $this->item;
$note = $this->note; $note = $this->note;
$botname = ($this->settings->slack_botname) ? $this->settings->slack_botname : 'Snipe-Bot'; $botname = ($this->settings->webhook_botname) ? $this->settings->webhook_botname : 'Snipe-Bot';
$fields = [ $fields = [
'QTY' => $qty, 'QTY' => $qty,

View file

@ -253,7 +253,7 @@ return [
'signature' => 'Signature', 'signature' => 'Signature',
'signed_off_by' => 'Signed Off By', 'signed_off_by' => 'Signed Off By',
'skin' => 'Skin', 'skin' => 'Skin',
'webhook_msg_note' => 'A :app message will be sent', 'webhook_msg_note' => 'A notification will be sent via webhook',
'webhook_test_msg' => 'Oh hai! Looks like your :app integration with Snipe-IT is working!', 'webhook_test_msg' => 'Oh hai! Looks like your :app integration with Snipe-IT is working!',
'some_features_disabled' => 'DEMO MODE: Some features are disabled for this installation.', 'some_features_disabled' => 'DEMO MODE: Some features are disabled for this installation.',
'site_name' => 'Site Name', 'site_name' => 'Site Name',

View file

@ -54,7 +54,7 @@
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to']) @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to'])
@if ($accessory->requireAcceptance() || $accessory->getEula() || ($snipeSettings->slack_endpoint!='')) @if ($accessory->requireAcceptance() || $accessory->getEula() || ($snipeSettings->webhook_endpoint!=''))
<div class="form-group notification-callout"> <div class="form-group notification-callout">
<div class="col-md-8 col-md-offset-3"> <div class="col-md-8 col-md-offset-3">
<div class="callout callout-info"> <div class="callout callout-info">
@ -71,9 +71,9 @@
<br> <br>
@endif @endif
@if ($snipeSettings->slack_endpoint!='') @if ($snipeSettings->webhook_endpoint!='')
<i class="fab fa-slack"></i> <i class="fab fa-slack"></i>
A slack message will be sent {{ trans('general.webhook_msg_note') }}
@endif @endif
</div> </div>
</div> </div>

View file

@ -41,7 +41,7 @@
@include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to', 'required'=> 'true']) @include ('partials.forms.edit.user-select', ['translated_name' => trans('general.select_user'), 'fieldname' => 'assigned_to', 'required'=> 'true'])
@if ($consumable->requireAcceptance() || $consumable->getEula() || ($snipeSettings->slack_endpoint!='')) @if ($consumable->requireAcceptance() || $consumable->getEula() || ($snipeSettings->webhook_endpoint!=''))
<div class="form-group notification-callout"> <div class="form-group notification-callout">
<div class="col-md-8 col-md-offset-3"> <div class="col-md-8 col-md-offset-3">
<div class="callout callout-info"> <div class="callout callout-info">
@ -58,9 +58,9 @@
<br> <br>
@endif @endif
@if ($snipeSettings->slack_endpoint!='') @if ($snipeSettings->webhook_endpoint!='')
<i class="fab fa-slack"></i> <i class="fab fa-slack"></i>
{{ trans('general.slack_msg_note') }} {{ trans('general.webhook_msg_note') }}
@endif @endif
</div> </div>
</div> </div>

View file

@ -114,7 +114,7 @@
</div> </div>
</div> </div>
@if ($asset->requireAcceptance() || $asset->getEula() || ($snipeSettings->slack_endpoint!='')) @if ($asset->requireAcceptance() || $asset->getEula() || ($snipeSettings->webhook_endpoint!=''))
<div class="form-group notification-callout"> <div class="form-group notification-callout">
<div class="col-md-8 col-md-offset-3"> <div class="col-md-8 col-md-offset-3">
<div class="callout callout-info"> <div class="callout callout-info">
@ -131,9 +131,9 @@
<br> <br>
@endif @endif
@if ($snipeSettings->slack_endpoint!='') @if ($snipeSettings->webhook_endpoint!='')
<i class="fab fa-slack" aria-hidden="true"></i> <i class="fab fa-slack" aria-hidden="true"></i>
{{ trans('general.slack_msg_note')}} {{ trans('general.webhook_msg_note') }}
@endif @endif
</div> </div>
</div> </div>

View file

@ -65,7 +65,7 @@
</div> </div>
@if ($license->requireAcceptance() || $license->getEula() || ($snipeSettings->slack_endpoint!='')) @if ($license->requireAcceptance() || $license->getEula() || ($snipeSettings->webhook_endpoint!=''))
<div class="form-group notification-callout"> <div class="form-group notification-callout">
<div class="col-md-8 col-md-offset-3"> <div class="col-md-8 col-md-offset-3">
<div class="callout callout-info"> <div class="callout callout-info">
@ -88,9 +88,9 @@
<br> <br>
@endif @endif
@if ($snipeSettings->slack_endpoint!='') @if ($snipeSettings->webhook_endpoint!='')
<i class="fab fa-slack"></i> <i class="fab fa-slack"></i>
{{ trans('general.slack_msg_note') }} {{ trans('general.webhook_msg_note') }}
@endif @endif
</div> </div>
</div> </div>