From 2f838416b02bb310529276ef4a585bd21d0981cd Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Sun, 2 Apr 2017 11:33:39 +0300 Subject: [PATCH] Check archived invoices aren't emailed through the API --- app/Http/Controllers/InvoiceApiController.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/InvoiceApiController.php b/app/Http/Controllers/InvoiceApiController.php index 6f692641f4e9..b948e28960e0 100644 --- a/app/Http/Controllers/InvoiceApiController.php +++ b/app/Http/Controllers/InvoiceApiController.php @@ -309,10 +309,15 @@ class InvoiceApiController extends BaseAPIController { $invoice = $request->entity(); - $this->dispatch(new SendInvoiceEmail($invoice)); + //$this->dispatch(new SendInvoiceEmail($invoice)); + $result = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice); + + if ($result !== true) { + return $this->errorResponse($result, 500); + } - $response = json_encode(RESULT_SUCCESS, JSON_PRETTY_PRINT); $headers = Utils::getApiHeaders(); + $response = json_encode(RESULT_SUCCESS, JSON_PRETTY_PRINT); return Response::make($response, 200, $headers); }