mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
apply array_filter to cc emails to prevent errors
This commit is contained in:
parent
62d06b44d6
commit
2cc2b2b1df
|
@ -63,7 +63,7 @@ class CheckoutableListener
|
||||||
$adminCcEmail = $settings->admin_cc_email;
|
$adminCcEmail = $settings->admin_cc_email;
|
||||||
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
||||||
}
|
}
|
||||||
$ccEmails = array_merge($alertsEmailsArray, $adminCcEmailsArray);
|
$ccEmails = array_filter(array_merge($alertsEmailsArray, $adminCcEmailsArray));
|
||||||
$notifiable = $event->checkedOutTo;
|
$notifiable = $event->checkedOutTo;
|
||||||
$mailable = $this->getCheckoutMailType($event, $acceptance);
|
$mailable = $this->getCheckoutMailType($event, $acceptance);
|
||||||
// Send email notifications
|
// Send email notifications
|
||||||
|
@ -136,8 +136,7 @@ class CheckoutableListener
|
||||||
$adminCcEmail = $settings->admin_cc_email;
|
$adminCcEmail = $settings->admin_cc_email;
|
||||||
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
||||||
}
|
}
|
||||||
$ccEmails = array_merge($alertsEmailsArray, $adminCcEmailsArray);
|
$ccEmails = array_filter(array_merge($alertsEmailsArray, $adminCcEmailsArray));
|
||||||
|
|
||||||
$notifiable = $event->checkedOutTo;
|
$notifiable = $event->checkedOutTo;
|
||||||
$mailable = $this->getCheckinMailType($event);
|
$mailable = $this->getCheckinMailType($event);
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ use App\Models\Accessory;
|
||||||
use App\Models\Setting;
|
use App\Models\Setting;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use Illuminate\Bus\Queueable;
|
use Illuminate\Bus\Queueable;
|
||||||
use Illuminate\Notifications\Channels\SlackWebhookChannel;
|
|
||||||
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;
|
||||||
|
@ -56,7 +55,35 @@ class CheckoutAccessoryNotification extends Notification
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) {
|
if (Setting::getSettings()->webhook_selected == 'slack' || Setting::getSettings()->webhook_selected == 'general' ) {
|
||||||
$notifyBy[] = SlackWebhookChannel::class;
|
$notifyBy[] = 'slack';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only send notifications to users that have email addresses
|
||||||
|
*/
|
||||||
|
if ($this->target instanceof User && $this->target->email != '') {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the asset requires acceptance,
|
||||||
|
* so the user can accept or decline the asset
|
||||||
|
*/
|
||||||
|
if ($this->item->requireAcceptance()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if the item has a EULA, since the user should always receive it
|
||||||
|
*/
|
||||||
|
if ($this->item->getEula()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send an email if an email should be sent at checkin/checkout
|
||||||
|
*/
|
||||||
|
if ($this->item->checkin_email()) {
|
||||||
|
$notifyBy[1] = 'mail';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $notifyBy;
|
return $notifyBy;
|
||||||
|
@ -136,4 +163,31 @@ class CheckoutAccessoryNotification extends Notification
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the mail representation of the notification.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||||
|
*/
|
||||||
|
public function toMail()
|
||||||
|
{
|
||||||
|
Log::debug($this->item->getImageUrl());
|
||||||
|
$eula = $this->item->getEula();
|
||||||
|
$req_accept = $this->item->requireAcceptance();
|
||||||
|
|
||||||
|
$accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
|
||||||
|
|
||||||
|
return (new MailMessage)->markdown('notifications.markdown.checkout-accessory',
|
||||||
|
[
|
||||||
|
'item' => $this->item,
|
||||||
|
'admin' => $this->admin,
|
||||||
|
'note' => $this->note,
|
||||||
|
'target' => $this->target,
|
||||||
|
'eula' => $eula,
|
||||||
|
'req_accept' => $req_accept,
|
||||||
|
'accept_url' => $accept_url,
|
||||||
|
'checkout_qty' => $this->checkout_qty,
|
||||||
|
])
|
||||||
|
->subject(trans('mail.Confirm_accessory_delivery'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue