mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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
|
* Make a checkout acceptance and attach it in the notification
|
||||||
*/
|
*/
|
||||||
|
$settings = Setting::getSettings();
|
||||||
$acceptance = $this->getCheckoutAcceptance($event);
|
$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;
|
$notifiable = $event->checkedOutTo;
|
||||||
$mailable = $this->getCheckoutMailType($event, $acceptance);
|
$mailable = $this->getCheckoutMailType($event, $acceptance);
|
||||||
// Send email notifications
|
// Send email notifications
|
||||||
|
@ -68,8 +74,7 @@ class CheckoutableListener
|
||||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
||||||
|
Mail::to($notifiable)->cc($ccEmails)->send($mailable);
|
||||||
Mail::to($notifiable)->send($mailable);
|
|
||||||
Log::info('Sending email, Locale: ' . ($event->checkedOutTo->locale ?? 'default'));
|
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;
|
$notifiable = $event->checkedOutTo;
|
||||||
$mailable = $this->getCheckinMailType($event);
|
$mailable = $this->getCheckinMailType($event);
|
||||||
// Send email notifications
|
// Send email notifications
|
||||||
|
@ -130,7 +140,7 @@ class CheckoutableListener
|
||||||
if ($notifiable instanceof User && $notifiable->email != '') {
|
if ($notifiable instanceof User && $notifiable->email != '') {
|
||||||
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
if ($event->checkoutable->requireAcceptance() || $event->checkoutable->getEula() ||
|
||||||
(method_exists($event->checkoutable, 'checkin_email') && $event->checkoutable->checkin_email())) {
|
(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);
|
Log::info('Sending email, Locale: ' . $event->checkedOutTo->locale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,19 +34,10 @@ class CheckinAccessoryMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: trans('mail.Accessory_Checkin_Notification'),
|
subject: trans('mail.Accessory_Checkin_Notification'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,19 +43,10 @@ class CheckinAssetMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: trans('mail.Asset_Checkin_Notification'),
|
subject: trans('mail.Asset_Checkin_Notification'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,19 +34,10 @@ class CheckinLicenseMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: trans('mail.License_Checkin_Notification'),
|
subject: trans('mail.License_Checkin_Notification'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,10 @@ class CheckoutAccessoryMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: (trans('mail.Accessory_Checkout_Notification')),
|
subject: (trans('mail.Accessory_Checkout_Notification')),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,19 +52,10 @@ class CheckoutAssetMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: trans('mail.Asset_Checkout_Notification'),
|
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.
|
* Get the attachments for the message.
|
||||||
|
|
|
@ -37,19 +37,10 @@ class CheckoutConsumableMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: trans('mail.Confirm_consumable_delivery'),
|
subject: trans('mail.Confirm_consumable_delivery'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,19 +36,10 @@ class CheckoutLicenseMail extends Mailable
|
||||||
*/
|
*/
|
||||||
public function envelope(): Envelope
|
public function envelope(): Envelope
|
||||||
{
|
{
|
||||||
$from = null;
|
$from = new Address(env('MAIL_FROM_ADDR'));
|
||||||
$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);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new Envelope(
|
return new Envelope(
|
||||||
from: $from ?? new Address('default@example.com', 'Default Sender'),
|
from: $from,
|
||||||
cc: $cc,
|
|
||||||
subject: trans('mail.Confirm_license_delivery'),
|
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\ForgotPasswordController;
|
||||||
use App\Http\Controllers\Auth\ResetPasswordController;
|
use App\Http\Controllers\Auth\ResetPasswordController;
|
||||||
use App\Livewire\Importer;
|
use App\Livewire\Importer;
|
||||||
|
use App\Models\Asset;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
|
@ -549,3 +551,22 @@ Route::middleware(['auth'])->get(
|
||||||
'/',
|
'/',
|
||||||
[DashboardController::class, 'index']
|
[DashboardController::class, 'index']
|
||||||
)->name('home');
|
)->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