Remove checks for send_email

This commit is contained in:
David Bomba 2021-10-05 15:20:44 +11:00
parent 8ce94012fb
commit 2d791f26b7
8 changed files with 20 additions and 14 deletions

View File

@ -65,6 +65,9 @@ class InvitationController extends Controller
private function genericRouter(string $entity, string $invitation_key) private function genericRouter(string $entity, string $invitation_key)
{ {
if(!in_array($entity, ['invoice', 'credit', 'quote', 'recurring_invoice']))
return response()->json(['message' => 'Invalid resource request']);
$key = $entity.'_id'; $key = $entity.'_id';
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation'; $entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';
@ -133,6 +136,9 @@ class InvitationController extends Controller
private function returnRawPdf(string $entity, string $invitation_key) private function returnRawPdf(string $entity, string $invitation_key)
{ {
if(!in_array($entity, ['invoice', 'credit', 'quote', 'recurring_invoice']))
return response()->json(['message' => 'Invalid resource request']);
$key = $entity.'_id'; $key = $entity.'_id';
$entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation'; $entity_obj = 'App\Models\\'.ucfirst(Str::camel($entity)).'Invitation';

View File

@ -127,7 +127,7 @@ class EmailController extends BaseController
$entity_obj->invitations->each(function ($invitation) use ($data, $entity_string, $entity_obj, $template) { $entity_obj->invitations->each(function ($invitation) use ($data, $entity_string, $entity_obj, $template) {
if (!$invitation->contact->trashed() && $invitation->contact->send_email && $invitation->contact->email) { if (!$invitation->contact->trashed() && $invitation->contact->email) {
$entity_obj->service()->markSent()->save(); $entity_obj->service()->markSent()->save();

View File

@ -59,15 +59,15 @@ class SendRecurring implements ShouldQueue
public function handle() : void public function handle() : void
{ {
//reset all contacts here //reset all contacts here
$this->recurring_invoice->client->contacts()->update(['send_email' => false]); // $this->recurring_invoice->client->contacts()->update(['send_email' => false]);
$this->recurring_invoice->invitations->each(function ($invitation){ // $this->recurring_invoice->invitations->each(function ($invitation){
$contact = $invitation->contact; // $contact = $invitation->contact;
$contact->send_email = true; // $contact->send_email = true;
$contact->save(); // $contact->save();
}); // });
// Generate Standard Invoice // Generate Standard Invoice
$invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client); $invoice = RecurringInvoiceToInvoiceFactory::create($this->recurring_invoice, $this->recurring_invoice->client);
@ -153,7 +153,7 @@ class SendRecurring implements ShouldQueue
} }
//important catch all here - we should never leave contacts send_email to false incase they are permanently set to false in the future. //important catch all here - we should never leave contacts send_email to false incase they are permanently set to false in the future.
$this->recurring_invoice->client->contacts()->update(['send_email' => true]); // $this->recurring_invoice->client->contacts()->update(['send_email' => true]);
} }

View File

@ -395,7 +395,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices->first()->invitations->each(function ($invitation) use ($nmo) { $invoices->first()->invitations->each(function ($invitation) use ($nmo) {
if ($invitation->contact->send_email && $invitation->contact->email) { if ($invitation->contact->email) {
$nmo->to_user = $invitation->contact; $nmo->to_user = $invitation->contact;
NinjaMailerJob::dispatch($nmo); NinjaMailerJob::dispatch($nmo);
@ -459,7 +459,7 @@ class BaseDriver extends AbstractPaymentDriver
$invoices->first()->invitations->each(function ($invitation) use ($nmo){ $invoices->first()->invitations->each(function ($invitation) use ($nmo){
if (!$invitation->contact->trashed() && $invitation->contact->send_email && $invitation->contact->email) { if (!$invitation->contact->trashed() && $invitation->contact->email) {
$nmo->to_user = $invitation->contact; $nmo->to_user = $invitation->contact;
NinjaMailerJob::dispatch($nmo); NinjaMailerJob::dispatch($nmo);

View File

@ -44,7 +44,7 @@ class SendEmail
} }
$this->credit->invitations->each(function ($invitation) { $this->credit->invitations->each(function ($invitation) {
if (!$invitation->contact->trashed() && $invitation->contact->send_email && $invitation->contact->email) { if (!$invitation->contact->trashed() && $invitation->contact->email) {
$email_builder = (new CreditEmail())->build($invitation, $this->reminder_template); $email_builder = (new CreditEmail())->build($invitation, $this->reminder_template);
// EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company); // EmailCredit::dispatchNow($email_builder, $invitation, $invitation->company);

View File

@ -44,7 +44,7 @@ class SendEmail extends AbstractService
} }
$this->invoice->invitations->each(function ($invitation) { $this->invoice->invitations->each(function ($invitation) {
if (!$invitation->contact->trashed() && $invitation->contact->send_email && $invitation->contact->email) { if (!$invitation->contact->trashed() && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template); EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
} }
}); });

View File

@ -33,7 +33,7 @@ class SendEmail
public function run() public function run()
{ {
$this->payment->client->contacts->each(function ($contact) { $this->payment->client->contacts->each(function ($contact) {
if ($contact->send_email && $contact->email) { if ($contact->email) {
EmailPayment::dispatchNow($this->payment, $this->payment->company, $contact); EmailPayment::dispatchNow($this->payment, $this->payment->company, $contact);
} }
}); });

View File

@ -42,7 +42,7 @@ class SendEmail
} }
$this->quote->invitations->each(function ($invitation) { $this->quote->invitations->each(function ($invitation) {
if (!$invitation->contact->trashed() && $invitation->contact->send_email && $invitation->contact->email) { if (!$invitation->contact->trashed() && $invitation->contact->email) {
EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template); EmailEntity::dispatchNow($invitation, $invitation->company, $this->reminder_template);
} }
}); });