Rename incident events and fixes
This commit is contained in:
committed by
James Brooks
parent
a93472f544
commit
64ff4d73c2
@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class IncidentHasReportedEvent
|
||||
class IncidentWasReportedEvent
|
||||
{
|
||||
/**
|
||||
* The incident that has been reported.
|
||||
@@ -13,7 +13,7 @@ namespace CachetHQ\Cachet\Events;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
|
||||
class MaintenanceHasScheduledEvent
|
||||
class MaintenanceWasScheduledEvent
|
||||
{
|
||||
/**
|
||||
* The incident that has been reported.
|
||||
34
app/Events/SubscriberHasVerifiedEvent.php
Normal file
34
app/Events/SubscriberHasVerifiedEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Events;
|
||||
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
|
||||
class SubscriberHasVerifiedEvent
|
||||
{
|
||||
/**
|
||||
* The subscriber who has verified.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
public $subscriber;
|
||||
|
||||
/**
|
||||
* Create a new subscriber has subscribed event instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class SendIncidentEmailNotificationHandler
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(IncidentHasReportedEvent $event)
|
||||
public function handle(IncidentWasReportedEvent $event)
|
||||
{
|
||||
$incident = $this->presenter->decorate($event->incident);
|
||||
$component = $this->presenter->decorate($event->incident->component);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Handlers\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent;
|
||||
use CachetHQ\Cachet\Events\MaintenanceWasScheduledEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
@@ -59,11 +59,15 @@ class SendMaintenanceEmailNotificationHandler
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
<<<<<<< cc10f8f42347c5fdfe7e464bedd3a388059ebc4b
|
||||
* @param \CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent $event
|
||||
*
|
||||
* @return void
|
||||
=======
|
||||
* @param \CachetHQ\Cachet\Events\MaintenanceWasScheduledEvent $event
|
||||
>>>>>>> Rename incident events and fixes
|
||||
*/
|
||||
public function handle(MaintenanceHasScheduledEvent $event)
|
||||
public function handle(MaintenanceWasScheduledEvent $event)
|
||||
{
|
||||
$data = $this->presenter->decorate($event->incident);
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Handlers\Events;
|
||||
|
||||
use CachetHQ\Cachet\Events\SubscriberHasSubscribedEvent;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
|
||||
class SendSubscriberVerificationEmailHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\MailQueue
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* Create a new send subscriber verification email handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Events\CustomerHasSubscribedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(SubscriberHasSubscribedEvent $event)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $event->subscriber->email,
|
||||
'subject' => 'Confirm your subscription.',
|
||||
'link' => route('subscribe.verify', ['code' => $event->subscriber->verify_code]),
|
||||
'app_url' => env('APP_URL'),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.subscribers.verify-html',
|
||||
'text' => 'emails.subscribers.verify-text',
|
||||
], $mail, function (Message $message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Api;
|
||||
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -80,7 +80,7 @@ class IncidentController extends AbstractApiController
|
||||
}
|
||||
|
||||
if (array_get($incidentData, 'notify') && subscribers_enabled()) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
event(new IncidentWasReportedEvent($incident));
|
||||
}
|
||||
|
||||
return $this->item($incident);
|
||||
|
||||
@@ -46,7 +46,7 @@ class SubscriberController extends AbstractApiController
|
||||
public function postSubscribers()
|
||||
{
|
||||
try {
|
||||
$subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verified', false)));
|
||||
$subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false)));
|
||||
} catch (Exception $e) {
|
||||
throw new BadRequestHttpException();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentHasReportedEvent;
|
||||
use CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
@@ -133,7 +133,7 @@ class IncidentController extends Controller
|
||||
}
|
||||
|
||||
if (array_get($incidentData, 'notify') && subscribers_enabled()) {
|
||||
event(new IncidentHasReportedEvent($incident));
|
||||
event(new IncidentWasReportedEvent($incident));
|
||||
}
|
||||
|
||||
return Redirect::route('dashboard.incidents.add')
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace CachetHQ\Cachet\Http\Controllers\Dashboard;
|
||||
|
||||
use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent;
|
||||
use CachetHQ\Cachet\Events\MaintenanceWasScheduledEvent;
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
@@ -118,7 +118,7 @@ class ScheduleController extends Controller
|
||||
}
|
||||
|
||||
if (array_get($scheduleData, 'notify') && subscribers_enabled()) {
|
||||
event(new MaintenanceHasScheduledEvent($incident));
|
||||
event(new MaintenanceWasScheduledEvent($incident));
|
||||
}
|
||||
|
||||
return Redirect::route('dashboard.schedule.add')
|
||||
|
||||
@@ -57,10 +57,8 @@ class SubscriberController extends Controller
|
||||
*/
|
||||
public function createSubscriberAction()
|
||||
{
|
||||
$email = Binput::get('email');
|
||||
|
||||
try {
|
||||
$this->dispatch(new SubscribeSubscriberCommand($email));
|
||||
$this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
|
||||
} catch (ValidationException $e) {
|
||||
return Redirect::route('dashboard.subscribers.add')
|
||||
->withInput(Binput::all())
|
||||
@@ -68,8 +66,6 @@ class SubscriberController extends Controller
|
||||
->withErrors($e->getMessageBag());
|
||||
}
|
||||
|
||||
event(new CustomerHasSubscribedEvent($subscriber));
|
||||
|
||||
return Redirect::route('dashboard.subscribers.add')
|
||||
->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
|
||||
}
|
||||
|
||||
@@ -24,10 +24,10 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\SendSubscriberVerificationEmailHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Events\Incident\IncidentHasReportedEvent' => [
|
||||
'CachetHQ\Cachet\Events\Incident\IncidentWasReportedEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\Incident\SendIncidentEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Events\Incident\MaintenanceHasScheduledEvent' => [
|
||||
'CachetHQ\Cachet\Events\Incident\MaintenanceWasScheduledEvent' => [
|
||||
'CachetHQ\Cachet\Handlers\Events\Incident\SendMaintenanceEmailNotificationHandler',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -40,7 +40,7 @@ class SubscriberTest extends AbstractTestCase
|
||||
{
|
||||
$this->beUser();
|
||||
|
||||
$this->expectsEvents('CachetHQ\Cachet\Events\SubscriberHasSubscribedEvent');
|
||||
$this->expectsEvents('CachetHQ\Cachet\Events\Subscriber\SubscriberHasSubscribedEvent');
|
||||
|
||||
$this->post('/api/v1/subscribers', [
|
||||
'email' => 'james@cachethq.io',
|
||||
|
||||
Reference in New Issue
Block a user