Integrate Mail, Nexmo and Slack notifications into Cachet
This commit is contained in:
@@ -1,41 +0,0 @@
|
||||
<?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\Bus\Commands\System\Mail;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the test mail command class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class TestMailCommand
|
||||
{
|
||||
/**
|
||||
* The user to send the notification to.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Create a new test mail command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user)
|
||||
{
|
||||
$this->user = $user;
|
||||
}
|
||||
}
|
||||
@@ -22,15 +22,24 @@ final class IncidentWasReportedEvent implements IncidentEventInterface
|
||||
*/
|
||||
public $incident;
|
||||
|
||||
/**
|
||||
* Whether to notify that the incident was reported.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $notify;
|
||||
|
||||
/**
|
||||
* Create a new incident has reported event instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
* @param bool $notify
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Incident $incident)
|
||||
public function __construct(Incident $incident, $notify)
|
||||
{
|
||||
$this->incident = $incident;
|
||||
$this->notify = $notify;
|
||||
}
|
||||
}
|
||||
|
||||
50
app/Bus/Events/User/UserAcceptedInviteEvent.php
Normal file
50
app/Bus/Events/User/UserAcceptedInviteEvent.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?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\Bus\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user accepted invite event class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
final class UserAcceptedInviteEvent implements UserEventInterface
|
||||
{
|
||||
/**
|
||||
* The user that accepted the invite.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\User
|
||||
*/
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* The invite that the user accepted.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Invite
|
||||
*/
|
||||
public $invite;
|
||||
|
||||
/**
|
||||
* Create a new user accepted invite event class.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\User $user
|
||||
* @param \CachetHQ\Cachet\Models\Invite $invite
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(User $user, Invite $invite)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->invite = $invite;
|
||||
}
|
||||
}
|
||||
@@ -105,9 +105,7 @@ class ReportIncidentCommandHandler
|
||||
));
|
||||
}
|
||||
|
||||
$incident->update(['notify' => (bool) $command->notify]);
|
||||
|
||||
event(new IncidentWasReportedEvent($incident));
|
||||
event(new IncidentWasReportedEvent($incident, (bool) $command->notify));
|
||||
|
||||
return $incident;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasSubscribedEvent;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use CachetHQ\Cachet\Models\Subscription;
|
||||
use CachetHQ\Cachet\Notifications\Subscriber\VerifySubscriptionNotification;
|
||||
|
||||
/**
|
||||
* This is the subscribe subscriber command handler.
|
||||
@@ -59,6 +60,8 @@ class SubscribeSubscriberCommandHandler
|
||||
if ($command->verified) {
|
||||
dispatch(new VerifySubscriberCommand($subscriber));
|
||||
} else {
|
||||
$subscriber->notify(new VerifySubscriptionNotification());
|
||||
|
||||
event(new SubscriberHasSubscribedEvent($subscriber));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
<?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\Bus\Handlers\Commands\System\Mail;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Commands\System\Mail\TestMailCommand;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
|
||||
/**
|
||||
* This is the test mail command handler class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class TestMailCommandHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\Mailer
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* Create a test mail command handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the test mail command.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Commands\System\Mail\TestMailCommand $command
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(TestMailCommand $command)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $command->user->email,
|
||||
'subject' => trans('dashboard.settings.mail.email.subject'),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.system.test-html',
|
||||
'text' => 'emails.system.test-text',
|
||||
], $mail, function ($message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Commands\User;
|
||||
use CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand;
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent;
|
||||
use CachetHQ\Cachet\Models\Invite;
|
||||
use CachetHQ\Cachet\Notifications\User\InviteUserNotification;
|
||||
|
||||
/**
|
||||
* This is the invite user command handler.
|
||||
@@ -36,6 +37,8 @@ class InviteUserCommandHandler
|
||||
'email' => $email,
|
||||
]);
|
||||
|
||||
$invite->notify(new InviteUserNotification());
|
||||
|
||||
event(new UserWasInvitedEvent($invite));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,18 +14,10 @@ namespace CachetHQ\Cachet\Bus\Handlers\Events\Component;
|
||||
use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasUpdatedEvent;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
use CachetHQ\Cachet\Notifications\Component\ComponentStatusChangedNotification;
|
||||
|
||||
class SendComponentUpdateEmailNotificationHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\Mailer
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* The subscriber instance.
|
||||
*
|
||||
@@ -36,14 +28,12 @@ class SendComponentUpdateEmailNotificationHandler
|
||||
/**
|
||||
* Create a new send incident email notification handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer, Subscriber $subscriber)
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
|
||||
@@ -66,9 +56,9 @@ class SendComponentUpdateEmailNotificationHandler
|
||||
// First notify all global subscribers.
|
||||
$globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();
|
||||
|
||||
foreach ($globalSubscribers as $subscriber) {
|
||||
$this->notify($component, $subscriber);
|
||||
}
|
||||
$globalSubscribers->map(function ($subscriber) use ($component, $event) {
|
||||
$subscriber->notify(new ComponentStatusChangedNotification($component, $event->new_status));
|
||||
});
|
||||
|
||||
$notified = $globalSubscribers->pluck('id')->all();
|
||||
|
||||
@@ -81,37 +71,8 @@ class SendComponentUpdateEmailNotificationHandler
|
||||
return in_array($subscriber->id, $notified);
|
||||
});
|
||||
|
||||
foreach ($componentSubscribers as $subscriber) {
|
||||
$this->notify($component, $subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification to subscriber.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Component $component
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function notify(Component $component, Subscriber $subscriber)
|
||||
{
|
||||
$component = AutoPresenter::decorate($component);
|
||||
|
||||
$mail = [
|
||||
'subject' => trans('cachet.subscriber.email.component.subject'),
|
||||
'component_name' => $component->name,
|
||||
'component_human_status' => $component->human_status,
|
||||
];
|
||||
|
||||
$mail['email'] = $subscriber->email;
|
||||
$mail['manage_link'] = cachet_route('subscribe.manage', [$subscriber->verify_code]);
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.components.update-html',
|
||||
'text' => 'emails.components.update-text',
|
||||
], $mail, function ($message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
$componentSubscribers->map(function ($subscriber) use ($component, $event) {
|
||||
$subscriber->notify(new ComponentStatusChangedNotification($component, $event->new_status));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,19 +13,10 @@ namespace CachetHQ\Cachet\Bus\Handlers\Events\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
use CachetHQ\Cachet\Notifications\Incident\NewIncidentNotification;
|
||||
|
||||
class SendIncidentEmailNotificationHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\Mailer
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* The subscriber instance.
|
||||
*
|
||||
@@ -36,14 +27,12 @@ class SendIncidentEmailNotificationHandler
|
||||
/**
|
||||
* Create a new send incident email notification handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer, Subscriber $subscriber)
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
|
||||
@@ -56,23 +45,25 @@ class SendIncidentEmailNotificationHandler
|
||||
*/
|
||||
public function handle(IncidentWasReportedEvent $event)
|
||||
{
|
||||
if (!$event->incident->notify) {
|
||||
$incident = $event->incident;
|
||||
|
||||
if (!$event->notify) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only send emails for public incidents.
|
||||
if ($event->incident->visible === 0) {
|
||||
if (!$incident->visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First notify all global subscribers.
|
||||
$globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();
|
||||
|
||||
foreach ($globalSubscribers as $subscriber) {
|
||||
$this->notify($event, $subscriber);
|
||||
}
|
||||
$globalSubscribers->map(function ($subscriber) use ($incident) {
|
||||
$subscriber->notify(new NewIncidentNotification($incident));
|
||||
});
|
||||
|
||||
if (!$event->incident->component) {
|
||||
if (!$incident->component) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,53 +72,12 @@ class SendIncidentEmailNotificationHandler
|
||||
// Notify the remaining component specific subscribers.
|
||||
$componentSubscribers = $this->subscriber
|
||||
->isVerified()
|
||||
->forComponent($event->incident->component->id)
|
||||
->forComponent($incident->component->id)
|
||||
->get()
|
||||
->reject(function ($subscriber) use ($notified) {
|
||||
return in_array($subscriber->id, $notified);
|
||||
})->map(function ($subscriber) use ($incident) {
|
||||
$subscriber->notify(new NewIncidentNotification($incident));
|
||||
});
|
||||
|
||||
foreach ($componentSubscribers as $subscriber) {
|
||||
$this->notify($event, $subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification to subscriber.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Events\IncidentWasReportedEvent $event
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function notify(IncidentWasReportedEvent $event, $subscriber)
|
||||
{
|
||||
$incident = AutoPresenter::decorate($event->incident);
|
||||
$component = AutoPresenter::decorate($event->incident->component);
|
||||
|
||||
$mail = [
|
||||
'email' => $subscriber->email,
|
||||
'subject' => trans('cachet.subscriber.email.incident.subject', [
|
||||
'status' => $incident->human_status,
|
||||
'name' => $incident->name,
|
||||
]),
|
||||
'has_component' => ($event->incident->component) ? true : false,
|
||||
'component_name' => $component ? $component->name : null,
|
||||
'name' => $incident->name,
|
||||
'timestamp' => $incident->occurred_at_formatted,
|
||||
'status' => $incident->human_status,
|
||||
'html_content' => $incident->formatted_message,
|
||||
'text_content' => $incident->message,
|
||||
'token' => $subscriber->token,
|
||||
'manage_link' => cachet_route('subscribe.manage', [$subscriber->verify_code]),
|
||||
'unsubscribe_link' => cachet_route('subscribe.unsubscribe', [$subscriber->verify_code]),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.incidents.new-html',
|
||||
'text' => 'emails.incidents.new-text',
|
||||
], $mail, function (Message $message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<?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\Bus\Handlers\Events\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use CachetHQ\Cachet\Notifications\IncidentUpdate\IncidentUpdatedNotification;
|
||||
|
||||
class SendIncidentUpdateEmailNotificationHandler
|
||||
{
|
||||
/**
|
||||
* The subscriber instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Subscriber
|
||||
*/
|
||||
protected $subscriber;
|
||||
|
||||
/**
|
||||
* Create a new send incident email notification handler.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(IncidentUpdateWasReportedEvent $event)
|
||||
{
|
||||
$update = $event->update;
|
||||
$incident = $update->incident;
|
||||
|
||||
// Only send emails for public incidents.
|
||||
if (!$incident->visible) {
|
||||
return;
|
||||
}
|
||||
|
||||
// First notify all global subscribers.
|
||||
$globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();
|
||||
|
||||
$globalSubscribers->map(function ($subscriber) use ($update) {
|
||||
$subscriber->notify(new IncidentUpdatedNotification($update));
|
||||
});
|
||||
|
||||
if (!$incident->component) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notified = $globalSubscribers->pluck('id')->all();
|
||||
|
||||
// Notify the remaining component specific subscribers.
|
||||
$componentSubscribers = $this->subscriber
|
||||
->isVerified()
|
||||
->forComponent($incident->component->id)
|
||||
->get()
|
||||
->reject(function ($subscriber) use ($notified) {
|
||||
return in_array($subscriber->id, $notified);
|
||||
})->map(function ($subscriber) use ($incident) {
|
||||
$subscriber->notify(new IncidentUpdatedNotification($incident));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -13,9 +13,7 @@ namespace CachetHQ\Cachet\Bus\Handlers\Events\Schedule;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleEventInterface;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
use CachetHQ\Cachet\Notifications\Schedule\NewScheduleNotification;
|
||||
|
||||
/**
|
||||
* This is the send schedule event notification handler.
|
||||
@@ -24,13 +22,6 @@ use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
*/
|
||||
class SendScheduleEmailNotificationHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\MailQueue
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* The subscriber instance.
|
||||
*
|
||||
@@ -39,16 +30,14 @@ class SendScheduleEmailNotificationHandler
|
||||
protected $subscriber;
|
||||
|
||||
/**
|
||||
* Create a new send maintenance email notification handler.
|
||||
* Create a new send schedule email notification handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer, Subscriber $subscriber)
|
||||
public function __construct(Subscriber $subscriber)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
$this->subscriber = $subscriber;
|
||||
}
|
||||
|
||||
@@ -61,62 +50,11 @@ class SendScheduleEmailNotificationHandler
|
||||
*/
|
||||
public function handle(ScheduleEventInterface $event)
|
||||
{
|
||||
$schedule = $event->schedule;
|
||||
|
||||
// First notify all global subscribers.
|
||||
$globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();
|
||||
|
||||
foreach ($globalSubscribers as $subscriber) {
|
||||
$this->notify($event, $subscriber);
|
||||
}
|
||||
|
||||
$notified = $globalSubscribers->pluck('id')->all();
|
||||
|
||||
// Notify the remaining component specific subscribers.
|
||||
$componentSubscribers = $this->subscriber
|
||||
->isVerified()
|
||||
->forComponent($event->incident->component->id)
|
||||
->get()
|
||||
->reject(function ($subscriber) use ($notified) {
|
||||
return in_array($subscriber->id, $notified);
|
||||
});
|
||||
|
||||
foreach ($componentSubscribers as $subscriber) {
|
||||
$this->notify($event, $subscriber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send notification to subscriber.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Events\Schedule\ScheduleEventInterface $event
|
||||
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Collection
|
||||
*/
|
||||
public function notify(ScheduleEventInterface $event, $subscriber)
|
||||
{
|
||||
$incident = AutoPresenter::decorate($event->incident);
|
||||
$component = AutoPresenter::decorate($event->incident->component);
|
||||
|
||||
$mail = [
|
||||
'email' => $subscriber->email,
|
||||
'subject' => trans('cachet.subscriber.email.maintenance.subject', [
|
||||
'name' => $incident->name,
|
||||
]),
|
||||
'name' => $incident->name,
|
||||
'timestamp' => $incident->scheduled_at_formatted,
|
||||
'status' => $incident->human_status,
|
||||
'html_content' => $incident->formatted_message,
|
||||
'text_content' => $incident->message,
|
||||
'token' => $subscriber->token,
|
||||
'manage_link' => cachet_route('subscribe.manage', [$subscriber->verify_code]),
|
||||
'unsubscribe_link' => cachet_route('subscribe.unsubscribe', [$subscriber->verify_code]),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.incidents.maintenance-html',
|
||||
'text' => 'emails.incidents.maintenance-text',
|
||||
], $mail, function (Message $message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
$globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get()->map(function ($subscriber) use ($schedule) {
|
||||
$subscriber->notify(new NewScheduleNotification($schedule));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<?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\Bus\Handlers\Events\Subscriber;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\Subscriber\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\Bus\Events\SubscriberHasSubscribedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(SubscriberHasSubscribedEvent $event)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $event->subscriber->email,
|
||||
'subject' => 'Confirm your subscription.',
|
||||
'link' => cachet_route('subscribe.verify', ['code' => $event->subscriber->verify_code]),
|
||||
];
|
||||
|
||||
$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']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<?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\Bus\Handlers\Events\User;
|
||||
|
||||
use CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent;
|
||||
use Illuminate\Contracts\Mail\MailQueue;
|
||||
use Illuminate\Mail\Message;
|
||||
|
||||
class SendInviteUserEmailHandler
|
||||
{
|
||||
/**
|
||||
* The mailer instance.
|
||||
*
|
||||
* @var \Illuminate\Contracts\Mail\MailQueue
|
||||
*/
|
||||
protected $mailer;
|
||||
|
||||
/**
|
||||
* Create a new send invite user email handler.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Mail\Mailer $mailer
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(MailQueue $mailer)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the event.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Bus\Events\UserWasInvitedEvent $event
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(UserWasInvitedEvent $event)
|
||||
{
|
||||
$mail = [
|
||||
'email' => $event->invite->email,
|
||||
'subject' => 'You have been invited.',
|
||||
'link' => cachet_route('signup.invite', [$event->invite->code]),
|
||||
];
|
||||
|
||||
$this->mailer->queue([
|
||||
'html' => 'emails.users.invite-html',
|
||||
'text' => 'emails.users.invite-text',
|
||||
], $mail, function (Message $message) use ($mail) {
|
||||
$message->to($mail['email'])->subject($mail['subject']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,7 @@ class ComposerServiceProvider extends ServiceProvider
|
||||
{
|
||||
$factory->composer('*', AppComposer::class);
|
||||
$factory->composer('*', CurrentUserComposer::class);
|
||||
$factory->composer(['index', 'single-incident', 'subscribe.*', 'signup', 'dashboard.settings.theme', 'emails.*'], ThemeComposer::class);
|
||||
$factory->composer(['index', 'single-incident', 'subscribe.*', 'signup', 'dashboard.settings.theme'], ThemeComposer::class);
|
||||
$factory->composer('dashboard.*', DashboardComposer::class);
|
||||
$factory->composer(['setup.*', 'dashboard.settings.localization'], TimezoneLocaleComposer::class);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent' => [
|
||||
//
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\IncidentUpdate\SendIncidentUpdateEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent' => [
|
||||
//
|
||||
@@ -91,7 +91,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasCreatedEvent' => [
|
||||
// 'CachetHQ\Cachet\Bus\Handlers\Events\Schedule\SendScheduleEmailNotificationHandler',
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\Schedule\SendScheduleEmailNotificationHandler',
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasRemovedEvent' => [
|
||||
//
|
||||
@@ -100,7 +100,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasSubscribedEvent' => [
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\Subscriber\SendSubscriberVerificationEmailHandler',
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasUnsubscribedEvent' => [
|
||||
//
|
||||
@@ -123,6 +123,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
'CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserAcceptedInviteEvent' => [
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserDisabledTwoAuthEvent' => [
|
||||
//
|
||||
],
|
||||
@@ -148,7 +151,7 @@ class EventServiceProvider extends ServiceProvider
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent' => [
|
||||
'CachetHQ\Cachet\Bus\Handlers\Events\User\SendInviteUserEmailHandler',
|
||||
//
|
||||
],
|
||||
'CachetHQ\Cachet\Bus\Events\User\UserWasRemovedEvent' => [
|
||||
//
|
||||
|
||||
@@ -15,6 +15,7 @@ use CachetHQ\Cachet\Bus\Commands\System\Config\UpdateConfigCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\System\Mail\TestMailCommand;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\Credits;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Cachet\Notifications\System\SystemTestNotification;
|
||||
use CachetHQ\Cachet\Settings\Repository;
|
||||
use Exception;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -294,7 +295,7 @@ class SettingsController extends Controller
|
||||
*/
|
||||
public function testMail()
|
||||
{
|
||||
dispatch(new TestMailCommand(Auth::user()));
|
||||
Auth::user()->notify(new SystemTestNotification());
|
||||
|
||||
return cachet_redirect('dashboard.settings.mail')
|
||||
->withSuccess(trans('dashboard.notifications.awesome'));
|
||||
|
||||
@@ -45,7 +45,7 @@ class ApiRoutes
|
||||
$router->get('incidents/templates', 'ApiController@getIncidentTemplate');
|
||||
$router->post('components/groups/order', 'ApiController@postUpdateComponentGroupOrder');
|
||||
$router->post('components/order', 'ApiController@postUpdateComponentOrder');
|
||||
$router->post('components/{component}', 'ApiController@postUpdateComponent');
|
||||
$router->any('components/{component}', 'ApiController@postUpdateComponent');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,9 +12,18 @@
|
||||
namespace CachetHQ\Cachet\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
|
||||
/**
|
||||
* This is the invite class.
|
||||
*
|
||||
* @author Joseph Cohen <joe@alt-three.com>
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class Invite extends Model
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
*
|
||||
@@ -42,21 +51,11 @@ class Invite extends Model
|
||||
|
||||
self::creating(function ($invite) {
|
||||
if (!$invite->code) {
|
||||
$invite->code = self::generateInviteCode();
|
||||
$invite->code = str_random(20);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an invite code.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function generateInviteCode()
|
||||
{
|
||||
return str_random(20);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the invite was claimed.
|
||||
*
|
||||
|
||||
@@ -15,11 +15,19 @@ use AltThree\Validator\ValidatingTrait;
|
||||
use CachetHQ\Cachet\Presenters\SubscriberPresenter;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use McCool\LaravelAutoPresenter\HasPresenter;
|
||||
|
||||
/**
|
||||
* This is the subscriber model.
|
||||
*
|
||||
* @author Joseph Cohen <joe@alt-three.com>
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class Subscriber extends Model implements HasPresenter
|
||||
{
|
||||
use ValidatingTrait;
|
||||
use Notifiable, ValidatingTrait;
|
||||
|
||||
/**
|
||||
* The attributes that should be casted to native types.
|
||||
@@ -145,6 +153,26 @@ class Subscriber extends Model implements HasPresenter
|
||||
return str_random(42);
|
||||
}
|
||||
|
||||
/**
|
||||
* Route notifications for the Nexmo channel.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function routeNotificationForNexmo()
|
||||
{
|
||||
return $this->phone_number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Route notifications for the Slack channel.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function routeNotificationForSlack()
|
||||
{
|
||||
return $this->slack_webhook_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the presenter class.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
<?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\Notifications\Component;
|
||||
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\NexmoMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
|
||||
/**
|
||||
* This is the component status changed notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class ComponentStatusChangedNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The component that changed.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Component
|
||||
*/
|
||||
protected $component;
|
||||
|
||||
/**
|
||||
* The component status we're now at.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $status;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Component $component
|
||||
* @param int $status
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Component $component, $status)
|
||||
{
|
||||
$this->component = AutoPresenter::decorate($component);
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail', 'nexmo', 'slack'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$content = trans('notifications.component.status_update.content', [
|
||||
'name' => $this->component->name,
|
||||
'old_status' => $this->component->human_status,
|
||||
'new_status' => trans("cachet.components.status.{$this->status}"),
|
||||
]);
|
||||
|
||||
if ($this->status <= 1) {
|
||||
$status = 'success';
|
||||
} else {
|
||||
$status = 'error';
|
||||
}
|
||||
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.component.status_update.subject'))
|
||||
->$status()
|
||||
->greeting(trans('notifications.component.status_update.title'))
|
||||
->line($content)
|
||||
->action('View Component', $this->component->link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Nexmo / SMS representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\NexmoMessage
|
||||
*/
|
||||
public function toNexmo($notifiable)
|
||||
{
|
||||
$content = trans('notifications.component.status_update.content', [
|
||||
'name' => $this->component->name,
|
||||
'old_status' => $this->component->human_status,
|
||||
'new_status' => trans("cachet.components.status.{$this->status}"),
|
||||
]);
|
||||
|
||||
return (new NexmoMessage())->content($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Slack representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\SlackMessage
|
||||
*/
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$content = trans('notifications.component.status_update.content', [
|
||||
'name' => $this->component->name,
|
||||
'old_status' => $this->component->human_status,
|
||||
'new_status' => trans("cachet.components.status.{$this->status}"),
|
||||
]);
|
||||
|
||||
$status = 'info';
|
||||
|
||||
if ($this->status <= 1) {
|
||||
$status = 'success';
|
||||
} elseif ($this->status === 2) {
|
||||
$status = 'warning';
|
||||
} elseif ($this->status >= 3) {
|
||||
$status = 'error';
|
||||
}
|
||||
|
||||
return (new SlackMessage())
|
||||
->$status()
|
||||
->content(trans('notifications.component.status_update.title'))
|
||||
->attachment(function ($attachment) use ($content) {
|
||||
$attachment->title($content, cachet_route('status-page'))
|
||||
->fields(array_filter([
|
||||
'Component' => $this->component->name,
|
||||
'Old Status' => $this->component->human_status,
|
||||
'New Status' => trans("cachet.components.status.{$this->status}"),
|
||||
'Link' => $this->component->link,
|
||||
]));
|
||||
});
|
||||
}
|
||||
}
|
||||
141
app/Notifications/Incident/NewIncidentNotification.php
Normal file
141
app/Notifications/Incident/NewIncidentNotification.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?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\Notifications\Incident;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\NexmoMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
|
||||
/**
|
||||
* This is the new incident notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class NewIncidentNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The incident.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
protected $incident;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Incident $incident
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Incident $incident)
|
||||
{
|
||||
$this->incident = AutoPresenter::decorate($incident);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail', 'nexmo', 'slack'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$content = trans('notifications.incident.new.content', [
|
||||
'name' => $this->incident->name,
|
||||
]);
|
||||
|
||||
if ($this->incident->status === Incident::FIXED) {
|
||||
$status = 'success';
|
||||
} else {
|
||||
$status = 'error';
|
||||
}
|
||||
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.incident.new.subject'))
|
||||
->$status()
|
||||
->greeting(trans('notifications.incident.new.title', ['app_name' => Config::get('setting.app_name')]))
|
||||
->line($content)
|
||||
->action('View Component', $this->incident->link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Nexmo / SMS representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\NexmoMessage
|
||||
*/
|
||||
public function toNexmo($notifiable)
|
||||
{
|
||||
$content = trans('notifications.incident.new.content', [
|
||||
'name' => $this->incident->name,
|
||||
]);
|
||||
|
||||
return (new NexmoMessage())->content($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Slack representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\SlackMessage
|
||||
*/
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$content = trans('notifications.incident.new.content', [
|
||||
'name' => $this->incident->name,
|
||||
]);
|
||||
|
||||
$status = 'info';
|
||||
|
||||
if ($this->incident->status === Incident::FIXED) {
|
||||
$status = 'success';
|
||||
} elseif ($this->incident->status === Incident::WATCHED) {
|
||||
$status = 'warning';
|
||||
} else {
|
||||
$status = 'error';
|
||||
}
|
||||
|
||||
return (new SlackMessage())
|
||||
->$status()
|
||||
->content(trans('notifications.incident.new.title', ['app_name' => Config::get('setting.app_name')]))
|
||||
->attachment(function ($attachment) use ($content) {
|
||||
$attachment->title($content)
|
||||
->timestamp($this->incident->getWrappedObject()->occurred_at)
|
||||
->fields(array_filter([
|
||||
'ID' => "#{$this->incident->id}",
|
||||
'Link' => $this->incident->permalink,
|
||||
]));
|
||||
});
|
||||
}
|
||||
}
|
||||
149
app/Notifications/IncidentUpdate/IncidentUpdatedNotification.php
Normal file
149
app/Notifications/IncidentUpdate/IncidentUpdatedNotification.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?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\Notifications\IncidentUpdate;
|
||||
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Cachet\Models\IncidentUpdate;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\NexmoMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
|
||||
/**
|
||||
* This is the incident updated notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class IncidentUpdatedNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The incident update.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Incident
|
||||
*/
|
||||
protected $update;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\IncidentUpdate $update
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(IncidentUpdate $update)
|
||||
{
|
||||
$this->update = AutoPresenter::decorate($update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail', 'nexmo', 'slack'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$content = trans('notifications.incident.update.content', [
|
||||
'name' => $this->update->name,
|
||||
'time' => $this->update->created_at_diff,
|
||||
]);
|
||||
|
||||
if ($this->update->status === Incident::FIXED) {
|
||||
$status = 'success';
|
||||
} else {
|
||||
$status = 'error';
|
||||
}
|
||||
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.incident.update.subject'))
|
||||
->$status()
|
||||
->greeting(trans('notifications.incident.update.title', [
|
||||
'name' => $this->update->incident->name,
|
||||
'new_status' => $this->update->human_status,
|
||||
]))
|
||||
->line($content)
|
||||
->action('View Component', $this->update->link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Nexmo / SMS representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\NexmoMessage
|
||||
*/
|
||||
public function toNexmo($notifiable)
|
||||
{
|
||||
$content = trans('notifications.incident.update.content', [
|
||||
'name' => $this->update->incident->name,
|
||||
]);
|
||||
|
||||
return (new NexmoMessage())->content($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Slack representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\SlackMessage
|
||||
*/
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$content = trans('notifications.incident.update.content', [
|
||||
'name' => $this->update->incident->name,
|
||||
]);
|
||||
|
||||
$status = 'info';
|
||||
|
||||
if ($this->update->status === Incident::FIXED) {
|
||||
$status = 'success';
|
||||
} elseif ($this->update->status === Incident::WATCHED) {
|
||||
$status = 'warning';
|
||||
} else {
|
||||
$status = 'error';
|
||||
}
|
||||
|
||||
return (new SlackMessage())
|
||||
->$status()
|
||||
->content(trans('notifications.incident.update.title', [
|
||||
'name' => $this->update->incident->name,
|
||||
'new_status' => $this->update->human_status,
|
||||
]))
|
||||
->attachment(function ($attachment) use ($content) {
|
||||
$attachment->title($content)
|
||||
->timestamp($this->update->getWrappedObject()->created_at)
|
||||
->fields(array_filter([
|
||||
'ID' => "#{$this->update->id}",
|
||||
'Link' => $this->update->permalink,
|
||||
]));
|
||||
});
|
||||
}
|
||||
}
|
||||
125
app/Notifications/Schedule/NewScheduleNotification.php
Normal file
125
app/Notifications/Schedule/NewScheduleNotification.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<?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\Notifications\Schedule;
|
||||
|
||||
use CachetHQ\Cachet\Models\Schedule;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Messages\NexmoMessage;
|
||||
use Illuminate\Notifications\Messages\SlackMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use McCool\LaravelAutoPresenter\Facades\AutoPresenter;
|
||||
|
||||
/**
|
||||
* This is the new schedule notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class NewScheduleNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* The schedule.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Models\Schedule
|
||||
*/
|
||||
protected $schedule;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Models\Schedule $schedule
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Schedule $schedule)
|
||||
{
|
||||
$this->schedule = AutoPresenter::decorate($schedule);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail', 'nexmo', 'slack'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
$content = trans('notifications.schedule.new.content', [
|
||||
'name' => $this->schedule->name,
|
||||
'date' => $this->schedule->scheduled_at_formatted,
|
||||
]);
|
||||
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.schedule.new.subject'))
|
||||
->greeting(trans('notifications.schedule.new.title'))
|
||||
->line($content)
|
||||
->action('View Component', $this->schedule->link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Nexmo / SMS representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\NexmoMessage
|
||||
*/
|
||||
public function toNexmo($notifiable)
|
||||
{
|
||||
$content = trans('notifications.schedule.new.content', [
|
||||
'name' => $this->schedule->name,
|
||||
'date' => $this->schedule->scheduled_at_formatted,
|
||||
]);
|
||||
|
||||
return (new NexmoMessage())->content($content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Slack representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\SlackMessage
|
||||
*/
|
||||
public function toSlack($notifiable)
|
||||
{
|
||||
$content = trans('notifications.schedule.new.content', [
|
||||
'name' => $this->schedule->name,
|
||||
'date' => $this->schedule->scheduled_at_formatted,
|
||||
]);
|
||||
|
||||
return (new SlackMessage())
|
||||
->content(trans('notifications.schedule.new.title'))
|
||||
->attachment(function ($attachment) use ($content) {
|
||||
$attachment->title($content)
|
||||
->timestamp($this->schedule->getWrappedObject()->scheduled_at)
|
||||
->fields(array_filter([
|
||||
'ID' => "#{$this->schedule->id}",
|
||||
'Status' => $this->schedule->human_status,
|
||||
]));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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\Notifications\Subscriber;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* This is the verify subscription notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class VerifySubscriptionNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.subscriber.verify.subject'))
|
||||
->greeting(trans('notifications.subscriber.verify.title', ['app_name' => Config::get('setting.app_name')]))
|
||||
->action(trans('notifications.subscriber.verify.action'), cachet_route('subscribe.verify', ['code' => $notifiable->verify_code]))
|
||||
->line(trans('notifications.subscriber.verify.content', ['app_name' => Config::get('setting.app_name')]));
|
||||
}
|
||||
}
|
||||
53
app/Notifications/System/SystemTestNotification.php
Normal file
53
app/Notifications/System/SystemTestNotification.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?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\Notifications\System;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
/**
|
||||
* This is the system test notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class SystemTestNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.system.test.subject'))
|
||||
->greeting(trans('notifications.system.test.title'))
|
||||
->line(trans('notifications.system.test.content'));
|
||||
}
|
||||
}
|
||||
55
app/Notifications/User/InviteUserNotification.php
Normal file
55
app/Notifications/User/InviteUserNotification.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\Notifications\User;
|
||||
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* This is the invite user notification class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class InviteUserNotification extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['mail'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
*
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage())
|
||||
->subject(trans('notifications.user.invite.subject'))
|
||||
->greeting(trans('notifications.user.invite.title', ['app_name' => Config::get('setting.app_name')]))
|
||||
->action(trans('notifications.user.invite.action'), cachet_route('signup.invite', [$notifiable->code]))
|
||||
->line(trans('notifications.user.invite.content', ['app_name' => Config::get('setting.app_name')]));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableSubscribersAddPhoneNumberSlackColumns extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('subscribers', function (Blueprint $table) {
|
||||
$table->string('phone_number')->nullable()->default(null)->after('verify_code');
|
||||
$table->string('slack_webhook_url')->nullable()->default(null)->after('phone_number');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('subscribers', function (Blueprint $table) {
|
||||
$table->dropColumn(['phone_number', 'slack_webhook_url']);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AlterTableComponentsMakeLinkNullable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('components', function (Blueprint $table) {
|
||||
$table->text('link')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -91,32 +91,6 @@ return [
|
||||
'unsubscribed' => 'Your email subscription has been cancelled.',
|
||||
'failure' => 'Something went wrong with the subscription.',
|
||||
'already-subscribed' => 'Cannot subscribe :email because they\'re already subscribed.',
|
||||
'verify' => [
|
||||
'text' => "Please confirm your email subscription to :app_name status updates.\n:link",
|
||||
'html' => '<p>Please confirm your email subscription to :app_name status updates.</p>',
|
||||
'button' => 'Confirm Subscription',
|
||||
],
|
||||
'maintenance' => [
|
||||
'subject' => '[Maintenance Scheduled] :name',
|
||||
],
|
||||
'incident' => [
|
||||
'subject' => '[New Incident] :status: :name',
|
||||
],
|
||||
'component' => [
|
||||
'subject' => 'Component Status Update',
|
||||
'text' => 'The component :component_name has seen a status change. The component is now at :component_human_status.\nThank you, :app_name',
|
||||
'html' => '<p>The component :component_name has seen a status change. The component is now at :component_human_status.</p><p>Thank you, :app_name</p>',
|
||||
'tooltip-title' => 'Subscribe to notifications for :component_name.',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
'users' => [
|
||||
'email' => [
|
||||
'invite' => [
|
||||
'text' => "You have been invited to the team :app_name status page, to sign up follow the next link.\n:link\nThank you, :app_name",
|
||||
'html' => '<p>You have been invited to the team :app_name status page, to sign up follow the next link.</p><p><a href=":link">:link</a></p><p>Thank you, :app_name</p>',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
65
resources/lang/en/notifications.php
Normal file
65
resources/lang/en/notifications.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
return [
|
||||
'component' => [
|
||||
'status_update' => [
|
||||
'subject' => 'Component Status Updated',
|
||||
'title' => 'A component\'s status was updated!',
|
||||
'content' => ':name status changed from :old_status to :new_status.',
|
||||
],
|
||||
],
|
||||
'incident' => [
|
||||
'new' => [
|
||||
'subject' => 'New Incident Reported',
|
||||
'content' => ':name was reported',
|
||||
'title' => 'A new incident was reported at :app_name status page.',
|
||||
'action' => 'View',
|
||||
],
|
||||
'update' => [
|
||||
'subject' => 'Incident Updated',
|
||||
'content' => ':name was updated',
|
||||
'title' => ':name was updated to :new_status',
|
||||
'action' => 'View',
|
||||
],
|
||||
],
|
||||
'schedule' => [
|
||||
'new' => [
|
||||
'subject' => 'New Schedule Created',
|
||||
'content' => ':name was scheduled for :date',
|
||||
'title' => 'A new scheduled maintenance was created.',
|
||||
'action' => 'View',
|
||||
],
|
||||
],
|
||||
'subscriber' => [
|
||||
'verify' => [
|
||||
'subject' => 'Verify Your Subscription',
|
||||
'content' => 'Click to verify your subscription to :app_name status page.',
|
||||
'title' => 'Verify your subscription to :app_name status page.',
|
||||
'action' => 'Verify',
|
||||
],
|
||||
],
|
||||
'system' => [
|
||||
'test' => [
|
||||
'subject' => 'Ping from Cachet!',
|
||||
'content' => 'This is a test notification from Cachet!',
|
||||
'title' => '🔔',
|
||||
],
|
||||
],
|
||||
'user' => [
|
||||
'invite' => [
|
||||
'subject' => 'Your invitation is inside...',
|
||||
'content' => 'You have been invited to join :app_name status page.',
|
||||
'title' => 'You\'re invited to join :app_name status page.',
|
||||
'action' => 'Accept',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -1,20 +0,0 @@
|
||||
@extends('layout.emails')
|
||||
|
||||
@section('content')
|
||||
{!! trans('cachet.subscriber.email.component.html', ['component_name' => $component_name, 'component_human_status' => $component_human_status, 'app_name' => $app_name]) !!}
|
||||
|
||||
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<div>
|
||||
<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{{ $manage_link }}" style="height:45px;v-text-anchor:middle;width:200px;" arcsize="7%" stroke="f" fill="t">
|
||||
<v:fill type="tile" color="#22BC66" />
|
||||
<w:anchorlock/>
|
||||
<center style="color:#ffffff;font-family:sans-serif;font-size:15px;">{!! trans('cachet.subscriber.email.manage') !!}</center>
|
||||
</v:roundrect><![endif]-->
|
||||
<a href="{{ $manage_link }}" class="button button--green">{!! trans('cachet.subscriber.email.manage') !!}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@stop
|
||||
@@ -1,7 +0,0 @@
|
||||
{!! trans('cachet.subscriber.email.component.text', ['component_name' => $component_name, 'component_human_status' => $component_human_status, 'app_name' => $app_name]) !!}
|
||||
|
||||
{!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }}
|
||||
|
||||
@if($show_support)
|
||||
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
|
||||
@endif
|
||||
@@ -1,40 +0,0 @@
|
||||
@extends('layout.emails')
|
||||
|
||||
@section('content')
|
||||
<h1 class="align-center">{!! $name !!}</h1>
|
||||
|
||||
<table class="border-rounded" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<p class="compressed">
|
||||
<strong>{!! $status !!}</strong>
|
||||
{!! $html_content !!}
|
||||
{!! $timestamp !!}
|
||||
</p>
|
||||
</td>
|
||||
<tr>
|
||||
</table>
|
||||
|
||||
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<div>
|
||||
<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{{ $manage_link }}" style="height:45px;v-text-anchor:middle;width:200px;" arcsize="7%" stroke="f" fill="t">
|
||||
<v:fill type="tile" color="#22BC66" />
|
||||
<w:anchorlock/>
|
||||
<center style="color:#ffffff;font-family:sans-serif;font-size:15px;">{!! trans('cachet.subscriber.email.manage') !!}</center>
|
||||
</v:roundrect><![endif]-->
|
||||
<a href="{{ $manage_link }}" class="button button--green">{!! trans('cachet.subscriber.email.manage') !!}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="body-sub" align="center">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p class="sub"><a href="{{ $unsubscribe_link }}">{!! trans('cachet.subscriber.email.unsubscribe') !!}</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@stop
|
||||
@@ -1,13 +0,0 @@
|
||||
{!! $name !!}
|
||||
|
||||
{!! $status !!}
|
||||
{!! $text_content !!}
|
||||
{!! $timestamp !!}
|
||||
|
||||
{!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }}
|
||||
|
||||
{!! trans('cachet.subscriber.email.unsubscribe') !!} {{ $unsubscribe_link }}
|
||||
|
||||
@if($show_support)
|
||||
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
|
||||
@endif
|
||||
@@ -1,40 +0,0 @@
|
||||
@extends('layout.emails')
|
||||
|
||||
@section('content')
|
||||
<h1 class="align-center">{!! $name !!}</h1>
|
||||
|
||||
<table class="border-rounded" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td>
|
||||
<p class="compressed">
|
||||
<strong>{!! $status !!} @if($has_component) ({{ $component_name }}) @endif</strong>
|
||||
{!! $html_content !!}
|
||||
{!! $timestamp !!}
|
||||
</p>
|
||||
</td>
|
||||
<tr>
|
||||
</table>
|
||||
|
||||
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<div>
|
||||
<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{{ $manage_link }}" style="height:45px;v-text-anchor:middle;width:200px;" arcsize="7%" stroke="f" fill="t">
|
||||
<v:fill type="tile" color="#22BC66" />
|
||||
<w:anchorlock/>
|
||||
<center style="color:#ffffff;font-family:sans-serif;font-size:15px;">{!! trans('cachet.subscriber.email.manage') !!}</center>
|
||||
</v:roundrect><![endif]-->
|
||||
<a href="{{ $manage_link }}" class="button button--green">{!! trans('cachet.subscriber.email.manage') !!}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table class="body-sub" align="center">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<p class="sub"><a href="{{ $unsubscribe_link }}">{!! trans('cachet.subscriber.email.unsubscribe') !!}</a></p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@stop
|
||||
@@ -1,17 +0,0 @@
|
||||
{!! $name !!}
|
||||
|
||||
{!! $status !!}
|
||||
{!! $text_content !!}
|
||||
{!! $timestamp !!}
|
||||
|
||||
@if($has_component)
|
||||
({{ $component_name }})
|
||||
@endif
|
||||
|
||||
{!! trans('cachet.subscriber.email.manage') !!} {{ $manage_link }}
|
||||
|
||||
{!! trans('cachet.subscriber.email.unsuscribe') !!} {{ $unsubscribe_link }}
|
||||
|
||||
@if($show_support)
|
||||
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
|
||||
@endif
|
||||
@@ -1,20 +0,0 @@
|
||||
@extends('layout.emails')
|
||||
|
||||
@section('content')
|
||||
{!! trans('cachet.subscriber.email.verify.html', ['app_name' => $app_name]) !!}
|
||||
|
||||
<table class="body-action" align="center" width="100%" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
<td align="center">
|
||||
<div>
|
||||
<!--[if mso]><v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="{{ $link }}" style="height:45px;v-text-anchor:middle;width:200px;" arcsize="7%" stroke="f" fill="t">
|
||||
<v:fill type="tile" color="#22BC66" />
|
||||
<w:anchorlock/>
|
||||
<center style="color:#ffffff;font-family:sans-serif;font-size:15px;">{{ trans('cachet.subscriber.email.verify.button') }}</center>
|
||||
</v:roundrect><![endif]-->
|
||||
<a href="{{ $link }}" class="button button--green">{{ trans('cachet.subscriber.email.verify.button') }}</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@stop
|
||||
@@ -1,5 +0,0 @@
|
||||
{{ trans('cachet.subscriber.email.verify.text', ['app_name' => $app_name, 'link' => $link]) }}
|
||||
|
||||
@if($show_support)
|
||||
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
|
||||
@endif
|
||||
@@ -1,5 +0,0 @@
|
||||
@extends('layout.emails')
|
||||
|
||||
@section('content')
|
||||
{{ trans('dashboard.settings.mail.email.body') }}
|
||||
@stop
|
||||
@@ -1,5 +0,0 @@
|
||||
{{ trans('dashboard.settings.mail.email.body') }}
|
||||
|
||||
@if($show_support)
|
||||
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
|
||||
@endif
|
||||
@@ -1,5 +0,0 @@
|
||||
@extends('layout.emails')
|
||||
|
||||
@section('content')
|
||||
{!! trans('cachet.users.email.invite.html', ['app_name' => $app_name, 'link' => $link]) !!}
|
||||
@stop
|
||||
@@ -1,5 +0,0 @@
|
||||
{{ trans('cachet.users.email.invite.text', ['app_name' => $app_name, 'link' => $link]) }}
|
||||
|
||||
@if($show_support)
|
||||
{!! trans('cachet.powered_by', ['app' => $app_name]) !!}
|
||||
@endif
|
||||
@@ -1,46 +0,0 @@
|
||||
<?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\Tests\Cachet\Bus\Commands\System\Mail;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Bus\Commands\System\Mail\TestMailCommand;
|
||||
use CachetHQ\Cachet\Bus\Handlers\Commands\System\Mail\TestMailCommandHandler;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the test mail command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
*/
|
||||
class TestMailCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
$object = new TestMailCommand($params['user']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return TestMailCommandHandler::class;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user