uploader; $this->notifier->send('file_quarantined', $this->staff(), subject: $file, data: [ 'itemName' => $file->name, 'uploaderName' => $uploader->name ?? __('a deleted account'), 'threat' => $threat, ]); // The uploader hears it once. Without this check a staff member // who uploaded an infected file would get both messages, which // read as two different files. if ($uploader !== null && ! $this->staff()->contains(fn (User $staff): bool => $staff->is($uploader))) { $this->notifier->send('upload_blocked', [$uploader], subject: $file, data: [ 'itemName' => $file->name, 'threat' => $threat, ]); } } /** * @return \Illuminate\Support\Collection */ private function staff(): \Illuminate\Support\Collection { return User::query() ->where('type', UserType::Staff) ->where('active', true) ->get() ->filter(fn (User $staff): bool => $this->permissions->allows($staff, Permission::ReleaseQuarantinedFiles)) ->values(); } }