mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
corrected cc email behavior
This commit is contained in:
parent
1e9922a0b0
commit
1b5f4415ae
|
@ -50,7 +50,13 @@ class CheckoutableListener
|
|||
/**
|
||||
* Make a checkout acceptance and attach it in the notification
|
||||
*/
|
||||
$settings = Setting::getSettings();
|
||||
$acceptance = $this->getCheckoutAcceptance($event);
|
||||
$emailsArray = $settings->alert_email;
|
||||
$adminCcEmail = $settings->admin_cc_email;
|
||||
$alertsEmailsArray = array_map('trim', explode(',', $emailsArray));
|
||||
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
||||
$ccEmails = array_merge($alertsEmailsArray, $adminCcEmailsArray);
|
||||
$notifiable = $event->checkedOutTo;
|
||||
$mailable = $this->getCheckoutMailType($event, $acceptance);
|
||||
// Send email notifications
|
||||
|
@ -68,8 +74,7 @@ class CheckoutableListener
|
|||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||
|
||||
Mail::to($notifiable)->send($mailable);
|
||||
Mail::to($notifiable)->cc($ccEmails)->send($mailable);
|
||||
Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default'));
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +117,12 @@ class CheckoutableListener
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
$settings = Setting::getSettings();
|
||||
$emailsArray = $settings->alert_email;
|
||||
$adminCcEmail = $settings->admin_cc_email;
|
||||
$alertsEmailsArray = array_map('trim', explode(',', $emailsArray));
|
||||
$adminCcEmailsArray = array_map('trim', explode(',', $adminCcEmail));
|
||||
$ccEmails = array_merge($alertsEmailsArray, $adminCcEmailsArray);
|
||||
$notifiable = $event->checkedOutTo;
|
||||
$mailable = $this->getCheckinMailType($event);
|
||||
// Send email notifications
|
||||
|
@ -130,7 +140,7 @@ class CheckoutableListener
|
|||
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||
Mail::to($notifiable)->send($mailable);
|
||||
Mail::to($notifiable)->cc($ccEmails)->send($mailable);
|
||||
Log::info('Sending email, Locale: ' . $event->checkedOutTo->locale);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,19 +34,10 @@ class CheckinAccessoryMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: trans('mail.Accessory_Checkin_Notification'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -43,19 +43,10 @@ class CheckinAssetMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: trans('mail.Asset_Checkin_Notification'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,19 +34,10 @@ class CheckinLicenseMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: trans('mail.License_Checkin_Notification'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -37,18 +37,10 @@ class CheckoutAccessoryMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: (trans('mail.Accessory_Checkout_Notification')),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -52,19 +52,10 @@ class CheckoutAssetMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: trans('mail.Asset_Checkout_Notification'),
|
||||
);
|
||||
}
|
||||
|
@ -106,37 +97,6 @@ class CheckoutAssetMail extends Mailable
|
|||
],
|
||||
);
|
||||
}
|
||||
// public function build()
|
||||
// {
|
||||
// $this->item->load('assetstatus');
|
||||
// $eula = method_exists($this->item, 'getEula') ? $this->item->getEula() : '';
|
||||
// $req_accept = method_exists($this->item, 'requireAcceptance') ? $this->item->requireAcceptance() : 0;
|
||||
// $fields = [];
|
||||
//
|
||||
// // Check if the item has custom fields associated with it
|
||||
// if (($this->item->model) && ($this->item->model->fieldset)) {
|
||||
// $fields = $this->item->model->fieldset->fields;
|
||||
// }
|
||||
//
|
||||
// $accept_url = is_null($this->acceptance) ? null : route('account.accept.item', $this->acceptance);
|
||||
//
|
||||
// return $this
|
||||
// ->subject('Asset Checkout Notification')
|
||||
// ->markdown('notifications.markdown.checkout-asset')
|
||||
// ->with([
|
||||
// 'item' => $this->item,
|
||||
// 'admin' => $this->admin,
|
||||
// 'status' => $this->item->assetstatus?->name,
|
||||
// 'note' => $this->note,
|
||||
// 'target' => $this->target,
|
||||
// 'fields' => $fields,
|
||||
// 'eula' => $eula,
|
||||
// 'req_accept' => $req_accept,
|
||||
// 'accept_url' => $accept_url,
|
||||
// 'last_checkout' => $this->last_checkout,
|
||||
// 'expected_checkin' => $this->expected_checkin,
|
||||
// ]);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Get the attachments for the message.
|
||||
|
|
|
@ -37,19 +37,10 @@ class CheckoutConsumableMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: trans('mail.Confirm_consumable_delivery'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -36,19 +36,10 @@ class CheckoutLicenseMail extends Mailable
|
|||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
$from = null;
|
||||
$cc = [];
|
||||
|
||||
if (!empty(Setting::getSettings()->alert_email)) {
|
||||
$from = new Address(Setting::getSettings()->alert_email);
|
||||
}
|
||||
if (!empty(Setting::getSettings()->admin_cc_email)) {
|
||||
$cc[] = new Address(Setting::getSettings()->admin_cc_email);
|
||||
}
|
||||
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||
|
||||
return new Envelope(
|
||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
||||
cc: $cc,
|
||||
from: $from,
|
||||
subject: trans('mail.Confirm_license_delivery'),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ use App\Http\Controllers\Auth\LoginController;
|
|||
use App\Http\Controllers\Auth\ForgotPasswordController;
|
||||
use App\Http\Controllers\Auth\ResetPasswordController;
|
||||
use App\Livewire\Importer;
|
||||
use App\Models\Asset;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
|
@ -549,3 +551,22 @@ 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);
|
||||
$acceptance = null; // Simulate acceptance data
|
||||
$note = 'Test note';
|
||||
|
||||
$fields = [];
|
||||
if (($item->model) && ($item->model->fieldset)) {
|
||||
$fields = $item->model->fieldset->fields;
|
||||
}
|
||||
|
||||
return new \App\Mail\CheckoutAssetMail(
|
||||
$item,
|
||||
$admin,
|
||||
$target,
|
||||
$acceptance,
|
||||
$note);
|
||||
});
|
Loading…
Reference in a new issue