Do not send notifications to archived/deleted users

This commit is contained in:
David Bomba 2022-04-07 08:52:10 +10:00
parent 7174939fe0
commit 912d0aebc5
2 changed files with 4 additions and 4 deletions

View File

@ -64,7 +64,7 @@ class InvoiceCreatedNotification implements ShouldQueue
/* Returns an array of notification methods */ /* Returns an array of notification methods */
$methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']); $methods = $this->findUserNotificationTypes($invoice->invitations()->first(), $company_user, 'invoice', ['all_notifications', 'invoice_created', 'invoice_created_all']);
/* If one of the methods is email then we fire the EntitySentMailer */ /* If one of the methods is email then we fire the EntitySentMailer */
// if (($key = array_search('mail', $methods))) {
if (($key = array_search('mail', $methods)) !== false) { if (($key = array_search('mail', $methods)) !== false) {
unset($methods[$key]); unset($methods[$key]);

View File

@ -32,7 +32,7 @@ trait UserNotifies
$notifiable_methods = []; $notifiable_methods = [];
$notifications = $company_user->notifications; $notifications = $company_user->notifications;
if ($company_user->company->is_disabled && is_array($notifications->email)) { if ($company_user->company->is_disabled && is_array($notifications->email) || $company_user->trashed() || $company_user->user->trashed()) {
return []; return [];
} }
@ -56,7 +56,7 @@ trait UserNotifies
$notifiable_methods = []; $notifiable_methods = [];
$notifications = $company_user->notifications; $notifications = $company_user->notifications;
if ($company_user->company->is_disabled || ! $notifications) { if ($company_user->company->is_disabled || ! $notifications || $company_user->trashed() || $company_user->user->trashed()) {
return []; return [];
} }
@ -125,7 +125,7 @@ trait UserNotifies
public function findCompanyUserNotificationType($company_user, $required_permissions) :array public function findCompanyUserNotificationType($company_user, $required_permissions) :array
{ {
if ($company_user->company->is_disabled) { if ($company_user->company->is_disabled || $company_user->trashed() || $company_user->user->trashed()) {
return []; return [];
} }