mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
send emails even if target has no email
This commit is contained in:
parent
7e996c40f5
commit
e65942064e
|
@ -73,14 +73,17 @@ class CheckoutableListener
|
|||
* 2. The item has a EULA
|
||||
* 3. The item should send an email at check-in/check-out
|
||||
*/
|
||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if ($notifiable instanceof User) {
|
||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||
Mail::to($notifiable)->cc($ccEmails)->send($mailable);
|
||||
if (!empty($notifiable->email)) {
|
||||
Mail::to($notifiable)->cc($ccEmails)->send($mailable);
|
||||
} else {
|
||||
Mail::cc($ccEmails)->send($mailable);
|
||||
}
|
||||
Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default'));
|
||||
}
|
||||
}
|
||||
|
||||
// Send Webhook notification
|
||||
if ($this->shouldSendWebhookNotification()) {
|
||||
Notification::route(Setting::getSettings()->webhook_selected, Setting::getSettings()->webhook_endpoint)
|
||||
|
|
|
@ -25,7 +25,9 @@ use App\Http\Controllers\Auth\ForgotPasswordController;
|
|||
use App\Http\Controllers\Auth\ResetPasswordController;
|
||||
use App\Livewire\Importer;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
@ -552,21 +554,32 @@ Route::middleware(['auth'])->get(
|
|||
[DashboardController::class, 'index']
|
||||
)->name('home');
|
||||
Route::get('/test-email', function() {
|
||||
$item = Asset::find(1); // Load some test data
|
||||
$admin = User::find(1);
|
||||
$target = User::find(2);
|
||||
$item = \App\Models\LicenseSeat::find(1); // Load some test data
|
||||
$admin = User::find(2);
|
||||
$target = User::find(1);
|
||||
$acceptance = null; // Simulate acceptance data
|
||||
$note = 'Test note';
|
||||
$settings = Setting::getSettings();
|
||||
$adminCcEmailsArray = [];
|
||||
|
||||
$fields = [];
|
||||
if (($item->model) && ($item->model->fieldset)) {
|
||||
$fields = $item->model->fieldset->fields;
|
||||
if($settings->admin_cc_email !== '') {
|
||||
$adminCcEmail = $settings->admin_cc_email;
|
||||
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
||||
}
|
||||
$ccEmails = array_filter($adminCcEmailsArray);
|
||||
if (!empty($target->email)) {
|
||||
Mail::to($target)->cc($ccEmails)->send( new \App\Mail\CheckoutLicenseMail(
|
||||
$item,
|
||||
$admin,
|
||||
$target,
|
||||
$acceptance,
|
||||
$note));
|
||||
} else {
|
||||
Mail::cc($ccEmails)->send(new \App\Mail\CheckoutLicenseMail(
|
||||
$item,
|
||||
$admin,
|
||||
$target,
|
||||
$acceptance,
|
||||
$note));
|
||||
}
|
||||
|
||||
return new \App\Mail\CheckoutAssetMail(
|
||||
$item,
|
||||
$admin,
|
||||
$target,
|
||||
$acceptance,
|
||||
$note);
|
||||
});
|
Loading…
Reference in a new issue