mirror of
https://github.com/snipe/snipe-it.git
synced 2025-02-02 08:21:09 -08:00
finished the construct and mail call in the listner
This commit is contained in:
parent
b29d032bf0
commit
f8476f7133
|
@ -3,6 +3,7 @@
|
||||||
namespace App\Listeners;
|
namespace App\Listeners;
|
||||||
|
|
||||||
use App\Events\CheckoutableCheckedOut;
|
use App\Events\CheckoutableCheckedOut;
|
||||||
|
use App\Mail\CheckoutAssetMail;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Models\CheckoutAcceptance;
|
use App\Models\CheckoutAcceptance;
|
||||||
|
@ -20,6 +21,7 @@ use App\Notifications\CheckoutAssetNotification;
|
||||||
use App\Notifications\CheckoutConsumableNotification;
|
use App\Notifications\CheckoutConsumableNotification;
|
||||||
use App\Notifications\CheckoutLicenseSeatNotification;
|
use App\Notifications\CheckoutLicenseSeatNotification;
|
||||||
use GuzzleHttp\Exception\ClientException;
|
use GuzzleHttp\Exception\ClientException;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
@ -44,23 +46,24 @@ class CheckoutableListener
|
||||||
* Make a checkout acceptance and attach it in the notification
|
* Make a checkout acceptance and attach it in the notification
|
||||||
*/
|
*/
|
||||||
$acceptance = $this->getCheckoutAcceptance($event);
|
$acceptance = $this->getCheckoutAcceptance($event);
|
||||||
$notifiables = $this->getNotifiables($event);
|
$notifiable = $this->getNotifiables($event);
|
||||||
|
$mailable = (new CheckoutAssetMail(
|
||||||
|
$event->checkoutable,
|
||||||
|
$event->checkedOutTo,
|
||||||
|
$event->checkedOutBy,
|
||||||
|
$acceptance,
|
||||||
|
$event->note
|
||||||
|
));
|
||||||
|
|
||||||
// Send email notifications
|
// Send email notifications
|
||||||
try {
|
try {
|
||||||
foreach ($notifiables as $notifiable) {
|
if (! $event->checkedOutTo->locale){
|
||||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
$mailable->locale($event->checkedOutTo->locale);
|
||||||
if (! $event->checkedOutTo->locale){
|
|
||||||
Notification::locale(Setting::getSettings()->locale)->send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Notification::send($notifiable, $this->getCheckoutNotification($event, $acceptance));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
Mail::to($notifiable)->send($mailable);
|
||||||
|
|
||||||
// Send Webhook notification
|
// Send Webhook notification
|
||||||
if ($this->shouldSendWebhookNotification()) {
|
if ($this->shouldSendWebhookNotification()) {
|
||||||
// Slack doesn't include the URL in its messaging format, so this is needed to hit the endpoint
|
// 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') {
|
if (Setting::getSettings()->webhook_selected === 'slack' || Setting::getSettings()->webhook_selected === 'general') {
|
||||||
Notification::route('slack', Setting::getSettings()->webhook_endpoint)
|
Notification::route('slack', Setting::getSettings()->webhook_endpoint)
|
||||||
|
|
Loading…
Reference in a new issue