Skip to content

A free open source IT asset/license management system

Adhere to admin_cc_always setting

Marcus Moored01f7cf3177e
diff --git a/app/Listeners/CheckoutableListener.php b/app/Listeners/CheckoutableListener.php
index e647bcd9e0..ec843b980b 100644
--- a/app/Listeners/CheckoutableListener.php
+++ b/app/Listeners/CheckoutableListener.php
@@ -69,16 +69,16 @@ class CheckoutableListener
return;
}
+ $acceptance = $this->getCheckoutAcceptance($event);
+
$shouldSendEmailToUser = $this->shouldSendCheckoutEmailToUser($event->checkoutable);
- $shouldSendEmailToAlertAddress = $this->shouldSendEmailToAlertAddress();
+ $shouldSendEmailToAlertAddress = $this->shouldSendEmailToAlertAddress($acceptance);
$shouldSendWebhookNotification = $this->shouldSendWebhookNotification();
if (!$shouldSendEmailToUser && !$shouldSendEmailToAlertAddress && !$shouldSendWebhookNotification) {
return;
}
- $acceptance = $this->getCheckoutAcceptance($event);
-
if ($shouldSendEmailToUser || $shouldSendEmailToAlertAddress) {
$mailable = $this->getCheckoutMailType($event, $acceptance);
$notifiable = $this->getNotifiableUser($event);
@@ -419,9 +419,19 @@ class CheckoutableListener
return false;
}
- private function shouldSendEmailToAlertAddress(): bool
+ private function shouldSendEmailToAlertAddress($acceptance = null): bool
{
- return Setting::getSettings() && Setting::getSettings()->admin_cc_email;
+ $setting = Setting::getSettings();
+
+ if (!$setting) {
+ return false;
+ }
+
+ if (is_null($acceptance) && !$setting->admin_cc_always) {
+ return false;
+ }
+
+ return (bool) $setting->admin_cc_email;
}
private function getFormattedAlertAddresses(): array