Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions app/Models/CheckoutAcceptance.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Notifications\Notifiable;
use TCPDF;

class CheckoutAcceptance extends Model
{
use HasFactory, Notifiable, SoftDeletes;
Expand All @@ -30,12 +29,11 @@ class CheckoutAcceptance extends Model
*/
public function routeNotificationForMail()
{
// At this point the endpoint is the same for everything.
// In the future this may want to be adapted for individual notifications.
$recipients_string = explode(',', Setting::getSettings()->alert_email);
$recipients = array_map('trim', $recipients_string);
$settings = Setting::getSettings();

$recipients = array_map('trim', explode(',', $settings->admin_cc_email ?? ''));

return array_filter($recipients);
return array_values(array_unique(array_filter($recipients)));
}

public function getCheckoutableItemTypeAttribute(): string
Expand Down
4 changes: 3 additions & 1 deletion app/Notifications/AcceptanceItemAcceptedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ public function via()

public function shouldSend($notifiable, $channel)
{
return Setting::getSettings()->alerts_enabled && !empty(Setting::getSettings()->alert_email);
$settings = Setting::getSettings();

return ($settings->alerts_enabled && !empty($settings->admin_cc_email));
}

/**
Expand Down
4 changes: 3 additions & 1 deletion app/Notifications/AcceptanceItemDeclinedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ public function via($notifiable)

public function shouldSend($notifiable, $channel)
{
return Setting::getSettings()->alerts_enabled && !empty(Setting::getSettings()->alert_email);
$settings = Setting::getSettings();

return ($settings->alerts_enabled && !empty($settings->admin_cc_email));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public function test_users_name_is_included_in_accessory_accepted_notification()
{
Notification::fake();

$this->settings->enableAlertEmail();
$this->settings->enableAdminCC();

$acceptance = CheckoutAcceptance::factory()
->pending()
Expand Down Expand Up @@ -120,7 +120,7 @@ public function test_users_name_is_included_in_accessory_declined_notification()
{
Notification::fake();

$this->settings->enableAlertEmail();
$this->settings->enableAdminCC();

$acceptance = CheckoutAcceptance::factory()
->pending()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function test_acceptance_email_includes_custom_fields_marked_show_in_emai
{
Event::fake([CheckoutAccepted::class]);
Notification::fake();
$this->settings->enableAlertEmail();
$this->settings->enableAdminCC();

$customField = CustomField::factory()->create([
'name' => 'Cost Center',
Expand Down Expand Up @@ -260,7 +260,7 @@ public function test_acceptance_note_cannot_inject_markdown_image_tag(): void
// <img> tag survives markdown parsing.
Event::fake([CheckoutAccepted::class]);
Notification::fake();

$this->settings->enableAdminCC();
$checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create();

$lfrPayload = '![x](/etc/hostname)';
Expand Down
Loading