diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 9f49bc067d2a..1cde7f5099b2 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -401,13 +401,8 @@ class InvoiceController extends BaseController if ($invoice->is_recurring) { $response = $this->emailRecurringInvoice($invoice); } else { - // TODO remove this with Laravel 5.3 (https://github.com/invoiceninja/invoiceninja/issues/1303) - if (config('queue.default') === 'sync') { - $response = app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice, $reminder, $pdfUpload, $template); - } else { - $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $pdfUpload, $template)); - $response = true; - } + $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $pdfUpload, $template)); + $response = true; } if ($response === true) { @@ -438,13 +433,8 @@ class InvoiceController extends BaseController if ($invoice->isPaid()) { return true; } else { - // TODO remove this with Laravel 5.3 (https://github.com/invoiceninja/invoiceninja/issues/1303) - if (config('queue.default') === 'sync') { - return app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice); - } else { - $this->dispatch(new SendInvoiceEmail($invoice)); - return true; - } + $this->dispatch(new SendInvoiceEmail($invoice)); + return true; } } diff --git a/app/Listeners/NotificationListener.php b/app/Listeners/NotificationListener.php index 744890a8ff4f..8772ef02e0ff 100644 --- a/app/Listeners/NotificationListener.php +++ b/app/Listeners/NotificationListener.php @@ -1,49 +1,20 @@ -userMailer = $userMailer; - $this->contactMailer = $contactMailer; - $this->pushService = $pushService; - } - /** * @param $invoice * @param $type @@ -51,9 +22,11 @@ class NotificationListener */ private function sendEmails($invoice, $type, $payment = null) { - foreach ($invoice->account->users as $user) { - if ($user->{"notify_{$type}"}) { - $this->userMailer->sendNotification($user, $invoice, $type, $payment); + foreach ($invoice->account->users as $user) + { + if ($user->{"notify_{$type}"}) + { + dispatch(new SendNotificationEmail($user, $invoice, $type, $payment)); } } } @@ -64,7 +37,7 @@ class NotificationListener public function emailedInvoice(InvoiceWasEmailed $event) { $this->sendEmails($event->invoice, 'sent'); - $this->pushService->sendNotification($event->invoice, 'sent'); + dispatch(new SendPushNotification($event->invoice, 'sent')); } /** @@ -73,7 +46,7 @@ class NotificationListener public function emailedQuote(QuoteWasEmailed $event) { $this->sendEmails($event->quote, 'sent'); - $this->pushService->sendNotification($event->quote, 'sent'); + dispatch(new SendPushNotification($event->quote, 'sent')); } /** @@ -81,12 +54,12 @@ class NotificationListener */ public function viewedInvoice(InvoiceInvitationWasViewed $event) { - if (! floatval($event->invoice->balance)) { + if ( ! floatval($event->invoice->balance)) { return; } $this->sendEmails($event->invoice, 'viewed'); - $this->pushService->sendNotification($event->invoice, 'viewed'); + dispatch(new SendPushNotification($event->invoice, 'viewed')); } /** @@ -99,7 +72,7 @@ class NotificationListener } $this->sendEmails($event->quote, 'viewed'); - $this->pushService->sendNotification($event->quote, 'viewed'); + dispatch(new SendPushNotification($event->quote, 'viewed')); } /** @@ -108,7 +81,7 @@ class NotificationListener public function approvedQuote(QuoteInvitationWasApproved $event) { $this->sendEmails($event->quote, 'approved'); - $this->pushService->sendNotification($event->quote, 'approved'); + dispatch(new SendPushNotification($event->quote, 'approved')); } /** @@ -117,13 +90,13 @@ class NotificationListener public function createdPayment(PaymentWasCreated $event) { // only send emails for online payments - if (! $event->payment->account_gateway_id) { + if ( ! $event->payment->account_gateway_id) { return; } - $this->contactMailer->sendPaymentConfirmation($event->payment); $this->sendEmails($event->payment->invoice, 'paid', $event->payment); - - $this->pushService->sendNotification($event->payment->invoice, 'paid'); + dispatch(new SendPaymentEmail($event->payment)); + dispatch(new SendPushNotification($event->payment->invoice, 'paid')); } + } diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index d03ea7b311e6..1a4b9e08b91e 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -789,12 +789,7 @@ class InvoiceRepository extends BaseRepository */ public function emailInvoice(Invoice $invoice) { - // TODO remove this with Laravel 5.3 (https://github.com/invoiceninja/invoiceninja/issues/1303) - if (config('queue.default') === 'sync') { - app('App\Ninja\Mailers\ContactMailer')->sendInvoice($invoice); - } else { - dispatch(new SendInvoiceEmail($invoice)); - } + dispatch(new SendInvoiceEmail($invoice)); } /**