/**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Bus\Events\Incident\IncidentWasReportedEvent $event
  *
  * @return void
  */
 public function handle(IncidentWasReportedEvent $event)
 {
     if (!$event->incident->notify) {
         return false;
     }
     // Only send emails for public incidents.
     if ($event->incident->visible === 0) {
         return;
     }
     // First notify all global subscribers.
     $globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();
     foreach ($globalSubscribers as $subscriber) {
         $this->notify($event, $subscriber);
     }
     if (!$event->incident->component) {
         return;
     }
     $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);
     }
 }
 /**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Events\MaintenanceHasScheduledEvent $event
  *
  * @return void
  */
 public function handle(MaintenanceWasScheduledEvent $event)
 {
     if (!$event->incident->notify) {
         return false;
     }
     $data = AutoPresenter::decorate($event->incident);
     foreach ($this->subscriber->isVerified()->get() as $subscriber) {
         $mail = ['email' => $subscriber->email, 'subject' => 'Scheduled maintenance.', 'status' => $data->humanStatus, 'html_content' => $data->formattedMessage, 'text_content' => $data->message, 'scheduled_at' => $data->scheduled_at_formatted, 'token' => $subscriber->token, 'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $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']);
         });
     }
 }
示例#3
0
 /**
  * Bind data to the view.
  *
  * @param \Illuminate\Contracts\View\View $view
  *
  * @return void
  */
 public function compose(View $view)
 {
     $view->withIncidentCount(Incident::notScheduled()->count());
     $view->withIncidentTemplateCount(IncidentTemplate::count());
     $view->withComponentCount(Component::all()->count());
     $view->withSubscriberCount(Subscriber::isVerified()->count());
 }
 /**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Events\Incident\IncidentHasReportedEvent $event
  *
  * @return void
  */
 public function handle(IncidentWasReportedEvent $event)
 {
     if (!$event->incident->notify) {
         return false;
     }
     $incident = AutoPresenter::decorate($event->incident);
     $component = AutoPresenter::decorate($event->incident->component);
     // Only send emails for public incidents.
     if ($event->incident->visible === 1) {
         foreach ($this->subscriber->isVerified()->get() as $subscriber) {
             $mail = ['email' => $subscriber->email, 'subject' => 'New incident reported.', 'has_component' => $event->incident->component ? true : false, 'component_name' => $component ? $component->name : null, 'status' => $incident->human_status, 'html_content' => $incident->formattedMessage, 'text_content' => $incident->message, 'token' => $subscriber->token, 'unsubscribe_link' => route('subscribe.unsubscribe', ['code' => $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']);
             });
         }
     }
 }
 /**
  * Handle the event.
  *
  * @param \CachetHQ\Cachet\Bus\Events\Component\ComponentWasUpdatedEvent $event
  *
  * @return void
  */
 public function handle(ComponentWasUpdatedEvent $event)
 {
     $component = $event->component;
     // First notify all global subscribers.
     $globalSubscribers = $this->subscriber->isVerified()->isGlobal()->get();
     foreach ($globalSubscribers as $subscriber) {
         $this->notify($component, $subscriber);
     }
     $notified = $globalSubscribers->pluck('id')->all();
     // Notify the remaining component specific subscribers.
     $componentSubscribers = $this->subscriber->isVerified()->forComponent($component->id)->get()->reject(function ($subscriber) use($notified) {
         return in_array($subscriber->id, $notified);
     });
     foreach ($componentSubscribers as $subscriber) {
         $this->notify($component, $subscriber);
     }
 }