mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 03:29:03 -05:00 
			
		
		
		
	Re-enable queue code
This commit is contained in:
		
							parent
							
								
									2d322bf2b3
								
							
						
					
					
						commit
						6ae4e63184
					
				@ -400,15 +400,10 @@ class InvoiceController extends BaseController
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if ($invoice->is_recurring) {
 | 
					        if ($invoice->is_recurring) {
 | 
				
			||||||
            $response = $this->emailRecurringInvoice($invoice);
 | 
					            $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 {
 | 
					        } else {
 | 
				
			||||||
            $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $pdfUpload, $template));
 | 
					            $this->dispatch(new SendInvoiceEmail($invoice, $reminder, $pdfUpload, $template));
 | 
				
			||||||
            $response = true;
 | 
					            $response = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($response === true) {
 | 
					        if ($response === true) {
 | 
				
			||||||
            $message = trans("texts.emailed_{$entityType}");
 | 
					            $message = trans("texts.emailed_{$entityType}");
 | 
				
			||||||
@ -437,16 +432,11 @@ class InvoiceController extends BaseController
 | 
				
			|||||||
        // in case auto-bill is enabled then a receipt has been sent
 | 
					        // in case auto-bill is enabled then a receipt has been sent
 | 
				
			||||||
        if ($invoice->isPaid()) {
 | 
					        if ($invoice->isPaid()) {
 | 
				
			||||||
            return true;
 | 
					            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 {
 | 
					        } else {
 | 
				
			||||||
            $this->dispatch(new SendInvoiceEmail($invoice));
 | 
					            $this->dispatch(new SendInvoiceEmail($invoice));
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * Display the specified resource.
 | 
					     * Display the specified resource.
 | 
				
			||||||
 | 
				
			|||||||
@ -1,49 +1,20 @@
 | 
				
			|||||||
<?php
 | 
					<?php namespace App\Listeners;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace App\Listeners;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use App\Events\InvoiceInvitationWasViewed;
 | 
					 | 
				
			||||||
use App\Events\InvoiceWasEmailed;
 | 
					use App\Events\InvoiceWasEmailed;
 | 
				
			||||||
use App\Events\PaymentWasCreated;
 | 
					 | 
				
			||||||
use App\Events\QuoteInvitationWasApproved;
 | 
					 | 
				
			||||||
use App\Events\QuoteInvitationWasViewed;
 | 
					 | 
				
			||||||
use App\Events\QuoteWasEmailed;
 | 
					use App\Events\QuoteWasEmailed;
 | 
				
			||||||
use App\Ninja\Mailers\ContactMailer;
 | 
					use App\Events\InvoiceInvitationWasViewed;
 | 
				
			||||||
use App\Ninja\Mailers\UserMailer;
 | 
					use App\Events\QuoteInvitationWasViewed;
 | 
				
			||||||
use App\Services\PushService;
 | 
					use App\Events\QuoteInvitationWasApproved;
 | 
				
			||||||
 | 
					use App\Events\PaymentWasCreated;
 | 
				
			||||||
 | 
					use App\Jobs\SendPaymentEmail;
 | 
				
			||||||
 | 
					use App\Jobs\SendNotificationEmail;
 | 
				
			||||||
 | 
					use App\Jobs\SendPushNotification;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Class NotificationListener.
 | 
					 * Class NotificationListener
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
class NotificationListener
 | 
					class NotificationListener
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @var UserMailer
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected $userMailer;
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @var ContactMailer
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected $contactMailer;
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * @var PushService
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    protected $pushService;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					 | 
				
			||||||
     * NotificationListener constructor.
 | 
					 | 
				
			||||||
     *
 | 
					 | 
				
			||||||
     * @param UserMailer    $userMailer
 | 
					 | 
				
			||||||
     * @param ContactMailer $contactMailer
 | 
					 | 
				
			||||||
     * @param PushService   $pushService
 | 
					 | 
				
			||||||
     */
 | 
					 | 
				
			||||||
    public function __construct(UserMailer $userMailer, ContactMailer $contactMailer, PushService $pushService)
 | 
					 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        $this->userMailer = $userMailer;
 | 
					 | 
				
			||||||
        $this->contactMailer = $contactMailer;
 | 
					 | 
				
			||||||
        $this->pushService = $pushService;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @param $invoice
 | 
					     * @param $invoice
 | 
				
			||||||
     * @param $type
 | 
					     * @param $type
 | 
				
			||||||
@ -51,9 +22,11 @@ class NotificationListener
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    private function sendEmails($invoice, $type, $payment = null)
 | 
					    private function sendEmails($invoice, $type, $payment = null)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        foreach ($invoice->account->users as $user) {
 | 
					        foreach ($invoice->account->users as $user)
 | 
				
			||||||
            if ($user->{"notify_{$type}"}) {
 | 
					        {
 | 
				
			||||||
                $this->userMailer->sendNotification($user, $invoice, $type, $payment);
 | 
					            if ($user->{"notify_{$type}"})
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                dispatch(new SendNotificationEmail($user, $invoice, $type, $payment));
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -64,7 +37,7 @@ class NotificationListener
 | 
				
			|||||||
    public function emailedInvoice(InvoiceWasEmailed $event)
 | 
					    public function emailedInvoice(InvoiceWasEmailed $event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->sendEmails($event->invoice, 'sent');
 | 
					        $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)
 | 
					    public function emailedQuote(QuoteWasEmailed $event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->sendEmails($event->quote, 'sent');
 | 
					        $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)
 | 
					    public function viewedInvoice(InvoiceInvitationWasViewed $event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if (! floatval($event->invoice->balance)) {
 | 
					        if ( ! floatval($event->invoice->balance)) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->sendEmails($event->invoice, 'viewed');
 | 
					        $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->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)
 | 
					    public function approvedQuote(QuoteInvitationWasApproved $event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $this->sendEmails($event->quote, 'approved');
 | 
					        $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)
 | 
					    public function createdPayment(PaymentWasCreated $event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // only send emails for online payments
 | 
					        // only send emails for online payments
 | 
				
			||||||
        if (! $event->payment->account_gateway_id) {
 | 
					        if ( ! $event->payment->account_gateway_id) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->contactMailer->sendPaymentConfirmation($event->payment);
 | 
					 | 
				
			||||||
        $this->sendEmails($event->payment->invoice, 'paid', $event->payment);
 | 
					        $this->sendEmails($event->payment->invoice, 'paid', $event->payment);
 | 
				
			||||||
 | 
					        dispatch(new SendPaymentEmail($event->payment));
 | 
				
			||||||
        $this->pushService->sendNotification($event->payment->invoice, 'paid');
 | 
					        dispatch(new SendPushNotification($event->payment->invoice, 'paid'));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -789,13 +789,8 @@ class InvoiceRepository extends BaseRepository
 | 
				
			|||||||
     */
 | 
					     */
 | 
				
			||||||
    public function emailInvoice(Invoice $invoice)
 | 
					    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));
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * @param Invoice $invoice
 | 
					     * @param Invoice $invoice
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user