Roll back notification queue changes

This commit is contained in:
Hillel Coren 2017-06-13 12:03:13 +03:00
parent 03367d1b60
commit ae357efaeb

View File

@ -1,20 +1,46 @@
<?php namespace App\Listeners; <?php namespace App\Listeners;
use App\Ninja\Mailers\UserMailer;
use App\Ninja\Mailers\ContactMailer;
use App\Events\InvoiceWasEmailed; use App\Events\InvoiceWasEmailed;
use App\Events\QuoteWasEmailed; use App\Events\QuoteWasEmailed;
use App\Events\InvoiceInvitationWasViewed; use App\Events\InvoiceInvitationWasViewed;
use App\Events\QuoteInvitationWasViewed; use App\Events\QuoteInvitationWasViewed;
use App\Events\QuoteInvitationWasApproved; use App\Events\QuoteInvitationWasApproved;
use App\Events\PaymentWasCreated; use App\Events\PaymentWasCreated;
use App\Jobs\SendPaymentEmail; use App\Services\PushService;
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
@ -37,7 +63,7 @@ class NotificationListener
public function emailedInvoice(InvoiceWasEmailed $event) public function emailedInvoice(InvoiceWasEmailed $event)
{ {
$this->sendEmails($event->invoice, 'sent', null, $event->notes); $this->sendEmails($event->invoice, 'sent', null, $event->notes);
dispatch(new SendPushNotification($event->invoice, 'sent')); $this->pushService->sendNotification($event->invoice, 'sent');
} }
/** /**
@ -46,7 +72,7 @@ class NotificationListener
public function emailedQuote(QuoteWasEmailed $event) public function emailedQuote(QuoteWasEmailed $event)
{ {
$this->sendEmails($event->quote, 'sent', null, $event->notes); $this->sendEmails($event->quote, 'sent', null, $event->notes);
dispatch(new SendPushNotification($event->quote, 'sent')); $this->pushService->sendNotification($event->quote, 'sent');
} }
/** /**
@ -59,7 +85,7 @@ class NotificationListener
} }
$this->sendEmails($event->invoice, 'viewed'); $this->sendEmails($event->invoice, 'viewed');
dispatch(new SendPushNotification($event->invoice, 'viewed')); $this->pushService->sendNotification($event->invoice, 'viewed');
} }
/** /**
@ -72,7 +98,7 @@ class NotificationListener
} }
$this->sendEmails($event->quote, 'viewed'); $this->sendEmails($event->quote, 'viewed');
dispatch(new SendPushNotification($event->quote, 'viewed')); $this->pushService->sendNotification($event->quote, 'viewed');
} }
/** /**
@ -81,7 +107,7 @@ class NotificationListener
public function approvedQuote(QuoteInvitationWasApproved $event) public function approvedQuote(QuoteInvitationWasApproved $event)
{ {
$this->sendEmails($event->quote, 'approved'); $this->sendEmails($event->quote, 'approved');
dispatch(new SendPushNotification($event->quote, 'approved')); $this->pushService->sendNotification($event->quote, 'approved');
} }
/** /**
@ -94,9 +120,10 @@ class NotificationListener
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));
dispatch(new SendPushNotification($event->payment->invoice, 'paid')); $this->pushService->sendNotification($event->payment->invoice, 'paid');
} }
} }