Patch for 5965 - multiple email recipients no longer working (#6238)

This commit is contained in:
snipe 2018-09-26 15:47:53 -07:00 committed by GitHub
parent b69b5fdf84
commit ffbee77f6f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 29 deletions

View file

@ -57,12 +57,12 @@ class SendExpectedCheckinAlerts extends Command
} }
} }
// Send a rollup to the admin, if settings dictate
$recipient = new \App\Models\Recipients\AlertRecipient();
if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) { if (($assets) && ($assets->count() > 0) && ($settings->alert_email != '')) {
$recipient->notify(new ExpectedCheckinAdminNotification($assets)); // Send a rollup to the admin, if settings dictate
$recipients = collect(explode(',', $settings->alert_email))->map(function ($item, $key) {
return new \App\Models\Recipients\AlertRecipient($item);
});
\Notification::send($recipients, new ExpectedCheckinAdminNotification($assets));
} }

View file

@ -50,26 +50,27 @@ class SendExpirationAlerts extends Command
$threshold = $settings->alert_interval; $threshold = $settings->alert_interval;
if (($settings->alert_email != '') && ($settings->alerts_enabled == 1)) {
// Send a rollup to the admin, if settings dictate
$recipients = collect(explode(',', $settings->alert_email))->map(function ($item, $key) {
return new \App\Models\Recipients\AlertRecipient($item);
});
// Expiring Assets // Expiring Assets
$assets = Asset::getExpiringWarrantee(Setting::getSettings()->alert_interval); $assets = Asset::getExpiringWarrantee(Setting::getSettings()->alert_interval);
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(), ['count'=>$assets->count(), 'threshold' => $threshold])); if ($assets->count() > 0) {
$this->info(trans_choice('mail.assets_warrantee_alert', $assets->count(),
['count' => $assets->count(), 'threshold' => $threshold]));
}
// Expiring licenses // Expiring licenses
$licenses = License::getExpiringLicenses($threshold); $licenses = License::getExpiringLicenses($threshold);
$this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count'=>$licenses->count(), 'threshold' => $threshold]));
$recipient = new \App\Models\Recipients\AlertRecipient();
if ((Setting::getSettings()->alert_email!='') && ($settings->alerts_enabled==1)) {
if ($assets->count() > 0) {
// Send a rollup to the admin, if settings dictate
$recipient->notify(new ExpiringAssetsNotification($assets, $threshold));
}
if ($licenses->count() > 0) { if ($licenses->count() > 0) {
$recipient->notify(new ExpiringLicenseNotification($licenses, $threshold)); $this->info(trans_choice('mail.license_expiring_alert', $licenses->count(), ['count' => $licenses->count(), 'threshold' => $threshold]));
\Notification::send($recipients, new ExpiringLicenseNotification($licenses, $threshold));
} }

View file

@ -50,13 +50,14 @@ class SendInventoryAlerts extends Command
$items = Helper::checkLowInventory(); $items = Helper::checkLowInventory();
// Send a rollup to the admin, if settings dictate // Send a rollup to the admin, if settings dictate
$recipient = new \App\Models\Recipients\AlertRecipient();
if (($items) && (count($items) > 0) && ($settings->alert_email!='')) {
if (($items) && (count($items) > 0)) {
$this->info(trans_choice('mail.low_inventory_alert', count($items))); $this->info(trans_choice('mail.low_inventory_alert', count($items)));
// Send a rollup to the admin, if settings dictate
$recipient->notify(new InventoryAlert($items, $settings->alert_threshold)); $recipients = collect(explode(',', $settings->alert_email))->map(function ($item, $key) {
return new \App\Models\Recipients\AlertRecipient($item);
});
\Notification::send($recipients, new InventoryAlert($items, $settings->alert_threshold));
} }
} else { } else {

View file

@ -5,10 +5,9 @@ use App\Models\Setting;
class AlertRecipient extends Recipient{ class AlertRecipient extends Recipient{
public function __construct() public function __construct(string $email)
{ {
$settings = Setting::getSettings(); $this->email = trim($email);
$this->email = $settings->alert_email;
} }
} }