1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5811 from turbo124/v5-develop

Add logging for duplicate reminder emails
This commit is contained in:
David Bomba 2021-05-25 12:59:11 +10:00 committed by GitHub
commit 63c4f585c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 7 deletions

View File

@ -47,9 +47,9 @@ class NinjaMailerJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels, MakesHash;
public $tries = 5; //number of retries
public $tries = 3; //number of retries
public $backoff = 5; //seconds to wait until retry
public $backoff = 10; //seconds to wait until retry
public $deleteWhenMissingModels = true;
@ -106,7 +106,7 @@ class NinjaMailerJob implements ShouldQueue
//send email
try {
nlog("trying to send");
nlog("trying to send to {$this->nmo->to_user->email} ". now()->toDateTimeString());
Mail::to($this->nmo->to_user->email)
->send($this->nmo->mailable);

View File

@ -48,22 +48,22 @@ class ReminderJob implements ShouldQueue
//multiDB environment, need to
foreach (MultiDB::$dbs as $db) {
MultiDB::setDB($db);
$this->processReminders($db);
$this->processReminders();
}
}
}
private function processReminders($db = null)
private function processReminders()
{
Invoice::where('next_send_date', Carbon::today()->format('Y-m-d'))->with('invitations')->cursor()->each(function ($invoice) {
if ($invoice->isPayable()) {
$reminder_template = $invoice->calculateTemplate('invoice');
$invoice->service()->touchReminder($reminder_template)->save();
$invoice->invitations->each(function ($invitation) use ($invoice, $reminder_template) {
EmailEntity::dispatch($invitation, $invitation->company, $reminder_template);
nlog("Firing email for invoice {$invoice->number}");
nlog("Firing reminder email for invoice {$invoice->number}");
});
if ($invoice->invitations->count() > 0) {
@ -73,6 +73,7 @@ class ReminderJob implements ShouldQueue
$invoice->next_send_date = null;
$invoice->save();
}
});
}
}