diff --git a/app/Bus/Commands/System/Mail/TestMailCommand.php b/app/Bus/Commands/System/Mail/TestMailCommand.php deleted file mode 100644 index 782ea873..00000000 --- a/app/Bus/Commands/System/Mail/TestMailCommand.php +++ /dev/null @@ -1,41 +0,0 @@ - - */ -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; - } -} diff --git a/app/Bus/Events/Incident/IncidentWasReportedEvent.php b/app/Bus/Events/Incident/IncidentWasReportedEvent.php index a93e7b02..9556b32f 100644 --- a/app/Bus/Events/Incident/IncidentWasReportedEvent.php +++ b/app/Bus/Events/Incident/IncidentWasReportedEvent.php @@ -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; } } diff --git a/app/Bus/Events/User/UserAcceptedInviteEvent.php b/app/Bus/Events/User/UserAcceptedInviteEvent.php new file mode 100644 index 00000000..3a040799 --- /dev/null +++ b/app/Bus/Events/User/UserAcceptedInviteEvent.php @@ -0,0 +1,50 @@ + + */ +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; + } +} diff --git a/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php b/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php index 0e46f78d..100ad8bf 100644 --- a/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php +++ b/app/Bus/Handlers/Commands/Incident/ReportIncidentCommandHandler.php @@ -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; } diff --git a/app/Bus/Handlers/Commands/Subscriber/SubscribeSubscriberCommandHandler.php b/app/Bus/Handlers/Commands/Subscriber/SubscribeSubscriberCommandHandler.php index dba6948f..3037d9ba 100644 --- a/app/Bus/Handlers/Commands/Subscriber/SubscribeSubscriberCommandHandler.php +++ b/app/Bus/Handlers/Commands/Subscriber/SubscribeSubscriberCommandHandler.php @@ -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)); } diff --git a/app/Bus/Handlers/Commands/System/Mail/TestMailCommandHandler.php b/app/Bus/Handlers/Commands/System/Mail/TestMailCommandHandler.php deleted file mode 100644 index 09d052c2..00000000 --- a/app/Bus/Handlers/Commands/System/Mail/TestMailCommandHandler.php +++ /dev/null @@ -1,64 +0,0 @@ - - */ -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']); - }); - } -} diff --git a/app/Bus/Handlers/Commands/User/InviteUserCommandHandler.php b/app/Bus/Handlers/Commands/User/InviteUserCommandHandler.php index fc515d5e..164a4220 100644 --- a/app/Bus/Handlers/Commands/User/InviteUserCommandHandler.php +++ b/app/Bus/Handlers/Commands/User/InviteUserCommandHandler.php @@ -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)); } } diff --git a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php index 7ed768a3..84eb6643 100644 --- a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php +++ b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php @@ -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)); }); } } diff --git a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php index cef908d9..b642bf1b 100644 --- a/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php +++ b/app/Bus/Handlers/Events/Incident/SendIncidentEmailNotificationHandler.php @@ -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']); - }); } } diff --git a/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php b/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php new file mode 100644 index 00000000..5a5090ad --- /dev/null +++ b/app/Bus/Handlers/Events/IncidentUpdate/SendIncidentUpdateEmailNotificationHandler.php @@ -0,0 +1,80 @@ +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)); + }); + } +} diff --git a/app/Bus/Handlers/Events/Schedule/SendScheduleEmailNotificationHandler.php b/app/Bus/Handlers/Events/Schedule/SendScheduleEmailNotificationHandler.php index 45d485f6..6a50b52a 100644 --- a/app/Bus/Handlers/Events/Schedule/SendScheduleEmailNotificationHandler.php +++ b/app/Bus/Handlers/Events/Schedule/SendScheduleEmailNotificationHandler.php @@ -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)); }); } } diff --git a/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php b/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php deleted file mode 100644 index fc07b405..00000000 --- a/app/Bus/Handlers/Events/Subscriber/SendSubscriberVerificationEmailHandler.php +++ /dev/null @@ -1,61 +0,0 @@ -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']); - }); - } -} diff --git a/app/Bus/Handlers/Events/User/SendInviteUserEmailHandler.php b/app/Bus/Handlers/Events/User/SendInviteUserEmailHandler.php deleted file mode 100644 index 12111cdf..00000000 --- a/app/Bus/Handlers/Events/User/SendInviteUserEmailHandler.php +++ /dev/null @@ -1,61 +0,0 @@ -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']); - }); - } -} diff --git a/app/Foundation/Providers/ComposerServiceProvider.php b/app/Foundation/Providers/ComposerServiceProvider.php index 5ca975cb..7472e246 100644 --- a/app/Foundation/Providers/ComposerServiceProvider.php +++ b/app/Foundation/Providers/ComposerServiceProvider.php @@ -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); diff --git a/app/Foundation/Providers/EventServiceProvider.php b/app/Foundation/Providers/EventServiceProvider.php index 7ee8d180..935b398c 100644 --- a/app/Foundation/Providers/EventServiceProvider.php +++ b/app/Foundation/Providers/EventServiceProvider.php @@ -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' => [ // diff --git a/app/Http/Controllers/Dashboard/SettingsController.php b/app/Http/Controllers/Dashboard/SettingsController.php index 36b1e8fa..a5c4fbd0 100644 --- a/app/Http/Controllers/Dashboard/SettingsController.php +++ b/app/Http/Controllers/Dashboard/SettingsController.php @@ -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')); diff --git a/app/Http/Routes/Dashboard/ApiRoutes.php b/app/Http/Routes/Dashboard/ApiRoutes.php index a07f9c4a..46d186dc 100644 --- a/app/Http/Routes/Dashboard/ApiRoutes.php +++ b/app/Http/Routes/Dashboard/ApiRoutes.php @@ -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'); }); } } diff --git a/app/Models/Invite.php b/app/Models/Invite.php index 6514c57f..b917b3f1 100644 --- a/app/Models/Invite.php +++ b/app/Models/Invite.php @@ -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 + * @author James Brooks + */ 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. * diff --git a/app/Models/Subscriber.php b/app/Models/Subscriber.php index 4ca768b2..f2527d77 100644 --- a/app/Models/Subscriber.php +++ b/app/Models/Subscriber.php @@ -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 + * @author James Brooks + * @author Graham Campbell + */ 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. * diff --git a/app/Notifications/Component/ComponentStatusChangedNotification.php b/app/Notifications/Component/ComponentStatusChangedNotification.php new file mode 100644 index 00000000..92378ffd --- /dev/null +++ b/app/Notifications/Component/ComponentStatusChangedNotification.php @@ -0,0 +1,156 @@ + + */ +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, + ])); + }); + } +} diff --git a/app/Notifications/Incident/NewIncidentNotification.php b/app/Notifications/Incident/NewIncidentNotification.php new file mode 100644 index 00000000..7be3fcbc --- /dev/null +++ b/app/Notifications/Incident/NewIncidentNotification.php @@ -0,0 +1,141 @@ + + */ +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, + ])); + }); + } +} diff --git a/app/Notifications/IncidentUpdate/IncidentUpdatedNotification.php b/app/Notifications/IncidentUpdate/IncidentUpdatedNotification.php new file mode 100644 index 00000000..bbde2a0c --- /dev/null +++ b/app/Notifications/IncidentUpdate/IncidentUpdatedNotification.php @@ -0,0 +1,149 @@ + + */ +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, + ])); + }); + } +} diff --git a/app/Notifications/Schedule/NewScheduleNotification.php b/app/Notifications/Schedule/NewScheduleNotification.php new file mode 100644 index 00000000..8c61b416 --- /dev/null +++ b/app/Notifications/Schedule/NewScheduleNotification.php @@ -0,0 +1,125 @@ + + */ +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, + ])); + }); + } +} diff --git a/app/Notifications/Subscriber/VerifySubscriptionNotification.php b/app/Notifications/Subscriber/VerifySubscriptionNotification.php new file mode 100644 index 00000000..f0c85306 --- /dev/null +++ b/app/Notifications/Subscriber/VerifySubscriptionNotification.php @@ -0,0 +1,55 @@ + + */ +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')])); + } +} diff --git a/app/Notifications/System/SystemTestNotification.php b/app/Notifications/System/SystemTestNotification.php new file mode 100644 index 00000000..747832a6 --- /dev/null +++ b/app/Notifications/System/SystemTestNotification.php @@ -0,0 +1,53 @@ + + */ +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')); + } +} diff --git a/app/Notifications/User/InviteUserNotification.php b/app/Notifications/User/InviteUserNotification.php new file mode 100644 index 00000000..519e0ab7 --- /dev/null +++ b/app/Notifications/User/InviteUserNotification.php @@ -0,0 +1,55 @@ + + */ +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')])); + } +} diff --git a/database/migrations/2016_12_29_124643_AlterTableSubscribersAddPhoneNumberSlackColumns.php b/database/migrations/2016_12_29_124643_AlterTableSubscribersAddPhoneNumberSlackColumns.php new file mode 100644 index 00000000..4b6cc024 --- /dev/null +++ b/database/migrations/2016_12_29_124643_AlterTableSubscribersAddPhoneNumberSlackColumns.php @@ -0,0 +1,42 @@ +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']); + }); + } +} diff --git a/database/migrations/2016_12_29_155956_AlterTableComponentsMakeLinkNullable.php b/database/migrations/2016_12_29_155956_AlterTableComponentsMakeLinkNullable.php new file mode 100644 index 00000000..47cd317e --- /dev/null +++ b/database/migrations/2016_12_29_155956_AlterTableComponentsMakeLinkNullable.php @@ -0,0 +1,39 @@ +text('link')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} diff --git a/resources/lang/en/cachet.php b/resources/lang/en/cachet.php index 9739f86d..3d208410 100644 --- a/resources/lang/en/cachet.php +++ b/resources/lang/en/cachet.php @@ -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' => '

Please confirm your email subscription to :app_name status updates.

', - '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' => '

The component :component_name has seen a status change. The component is now at :component_human_status.

Thank you, :app_name

', - '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' => '

You have been invited to the team :app_name status page, to sign up follow the next link.

:link

Thank you, :app_name

', - ], ], ], diff --git a/resources/lang/en/notifications.php b/resources/lang/en/notifications.php new file mode 100644 index 00000000..4db80e7c --- /dev/null +++ b/resources/lang/en/notifications.php @@ -0,0 +1,65 @@ + [ + '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', + ], + ], +]; diff --git a/resources/views/emails/components/update-html.blade.php b/resources/views/emails/components/update-html.blade.php deleted file mode 100644 index d99acb78..00000000 --- a/resources/views/emails/components/update-html.blade.php +++ /dev/null @@ -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]) !!} - - - - - -
- -
-@stop diff --git a/resources/views/emails/components/update-text.blade.php b/resources/views/emails/components/update-text.blade.php deleted file mode 100644 index 935a8e7e..00000000 --- a/resources/views/emails/components/update-text.blade.php +++ /dev/null @@ -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 diff --git a/resources/views/emails/incidents/maintenance-html.blade.php b/resources/views/emails/incidents/maintenance-html.blade.php deleted file mode 100644 index b5214925..00000000 --- a/resources/views/emails/incidents/maintenance-html.blade.php +++ /dev/null @@ -1,40 +0,0 @@ -@extends('layout.emails') - -@section('content') -

{!! $name !!}

- - - - - -
-

- {!! $status !!} - {!! $html_content !!} - {!! $timestamp !!} -

-
- - - - - -
- -
- - - - - -
-

{!! trans('cachet.subscriber.email.unsubscribe') !!}

-
-@stop diff --git a/resources/views/emails/incidents/maintenance-text.blade.php b/resources/views/emails/incidents/maintenance-text.blade.php deleted file mode 100644 index 6c2d54bb..00000000 --- a/resources/views/emails/incidents/maintenance-text.blade.php +++ /dev/null @@ -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 diff --git a/resources/views/emails/incidents/new-html.blade.php b/resources/views/emails/incidents/new-html.blade.php deleted file mode 100644 index c30598c0..00000000 --- a/resources/views/emails/incidents/new-html.blade.php +++ /dev/null @@ -1,40 +0,0 @@ -@extends('layout.emails') - -@section('content') -

{!! $name !!}

- - - - - -
-

- {!! $status !!} @if($has_component) ({{ $component_name }}) @endif - {!! $html_content !!} - {!! $timestamp !!} -

-
- - - - - -
- -
- - - - - -
-

{!! trans('cachet.subscriber.email.unsubscribe') !!}

-
-@stop diff --git a/resources/views/emails/incidents/new-text.blade.php b/resources/views/emails/incidents/new-text.blade.php deleted file mode 100644 index 80616d1e..00000000 --- a/resources/views/emails/incidents/new-text.blade.php +++ /dev/null @@ -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 diff --git a/resources/views/emails/subscribers/verify-html.blade.php b/resources/views/emails/subscribers/verify-html.blade.php deleted file mode 100644 index edc10009..00000000 --- a/resources/views/emails/subscribers/verify-html.blade.php +++ /dev/null @@ -1,20 +0,0 @@ -@extends('layout.emails') - -@section('content') -{!! trans('cachet.subscriber.email.verify.html', ['app_name' => $app_name]) !!} - - - - - -
- -
-@stop diff --git a/resources/views/emails/subscribers/verify-text.blade.php b/resources/views/emails/subscribers/verify-text.blade.php deleted file mode 100644 index b45eb8a6..00000000 --- a/resources/views/emails/subscribers/verify-text.blade.php +++ /dev/null @@ -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 diff --git a/resources/views/emails/system/test-html.blade.php b/resources/views/emails/system/test-html.blade.php deleted file mode 100644 index e04b9991..00000000 --- a/resources/views/emails/system/test-html.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends('layout.emails') - -@section('content') -{{ trans('dashboard.settings.mail.email.body') }} -@stop diff --git a/resources/views/emails/system/test-text.blade.php b/resources/views/emails/system/test-text.blade.php deleted file mode 100644 index 0fc6a49e..00000000 --- a/resources/views/emails/system/test-text.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -{{ trans('dashboard.settings.mail.email.body') }} - -@if($show_support) -{!! trans('cachet.powered_by', ['app' => $app_name]) !!} -@endif diff --git a/resources/views/emails/users/invite-html.blade.php b/resources/views/emails/users/invite-html.blade.php deleted file mode 100644 index 8a01d8fb..00000000 --- a/resources/views/emails/users/invite-html.blade.php +++ /dev/null @@ -1,5 +0,0 @@ -@extends('layout.emails') - -@section('content') -{!! trans('cachet.users.email.invite.html', ['app_name' => $app_name, 'link' => $link]) !!} -@stop diff --git a/resources/views/emails/users/invite-text.blade.php b/resources/views/emails/users/invite-text.blade.php deleted file mode 100644 index 2195b31a..00000000 --- a/resources/views/emails/users/invite-text.blade.php +++ /dev/null @@ -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 diff --git a/tests/Bus/Commands/System/Mail/TestMailCommandTest.php b/tests/Bus/Commands/System/Mail/TestMailCommandTest.php deleted file mode 100644 index 1e92f46e..00000000 --- a/tests/Bus/Commands/System/Mail/TestMailCommandTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - */ -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; - } -}