Uses queue when sending email through API

This commit is contained in:
Hillel Coren 2017-10-24 11:16:00 +03:00
parent b110702487
commit 640d9323a2

View File

@ -200,15 +200,13 @@ class InvoiceApiController extends BaseAPIController
if ($isEmailInvoice) {
if ($payment) {
app('App\Ninja\Mailers\ContactMailer')->sendPaymentConfirmation($payment);
//$this->dispatch(new SendPaymentEmail($payment));
$this->dispatch(new SendPaymentEmail($payment));
} else {
if ($invoice->is_recurring && $recurringInvoice = $this->invoiceRepo->createRecurringInvoice($invoice)) {
$invoice = $recurringInvoice;
}
$reminder = isset($data['email_type']) ? $data['email_type'] : false;
app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice, $reminder);
//$this->dispatch(new SendInvoiceEmail($invoice));
$this->dispatch(new SendInvoiceEmail($invoice, auth()->user()->id, $reminder));
}
}
@ -335,12 +333,14 @@ class InvoiceApiController extends BaseAPIController
$invoice = $recurringInvoice;
}
//$this->dispatch(new SendInvoiceEmail($invoice));
if (config('queue.default') !== 'sync') {
$this->dispatch(new SendInvoiceEmail($invoice, auth()->user()->id));
} else {
$result = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice);
if ($result !== true) {
return $this->errorResponse($result, 500);
}
}
$headers = Utils::getApiHeaders();
$response = json_encode(['message' => RESULT_SUCCESS], JSON_PRETTY_PRINT);