Added subcriber verified scope and already subscribed msg
This commit is contained in:
@@ -65,7 +65,7 @@ class SendIncidentEmailNotificationHandler
|
|||||||
|
|
||||||
// Only send emails for public incidents.
|
// Only send emails for public incidents.
|
||||||
if ($event->incident->visible === 1) {
|
if ($event->incident->visible === 1) {
|
||||||
foreach ($this->subscriber->all() as $subscriber) {
|
foreach ($this->subscriber->verified()->get() as $subscriber) {
|
||||||
$mail = [
|
$mail = [
|
||||||
'email' => $subscriber->email,
|
'email' => $subscriber->email,
|
||||||
'subject' => 'New incident reported.',
|
'subject' => 'New incident reported.',
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class SendMaintenanceEmailNotificationHandler
|
|||||||
|
|
||||||
$data = AutoPresenter::decorate($event->incident);
|
$data = AutoPresenter::decorate($event->incident);
|
||||||
|
|
||||||
foreach ($this->subscriber->all() as $subscriber) {
|
foreach ($this->subscriber->verified()->get() as $subscriber) {
|
||||||
$mail = [
|
$mail = [
|
||||||
'email' => $subscriber->email,
|
'email' => $subscriber->email,
|
||||||
'subject' => 'Scheduled maintenance.',
|
'subject' => 'Scheduled maintenance.',
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ use AltThree\Validator\ValidationException;
|
|||||||
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||||
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||||
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
|
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
|
||||||
|
use CachetHQ\Cachet\Exceptions\AlreadySubscribedException;
|
||||||
use CachetHQ\Cachet\Facades\Setting;
|
use CachetHQ\Cachet\Facades\Setting;
|
||||||
use CachetHQ\Cachet\Models\Subscriber;
|
use CachetHQ\Cachet\Models\Subscriber;
|
||||||
use GrahamCampbell\Binput\Facades\Binput;
|
use GrahamCampbell\Binput\Facades\Binput;
|
||||||
@@ -50,6 +51,10 @@ class SubscribeController extends Controller
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
|
$this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
|
||||||
|
} catch (AlreadySubscribedException $e) {
|
||||||
|
return Redirect::route('subscribe.subscribe')
|
||||||
|
->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))
|
||||||
|
->withErrors($e->getMessage());
|
||||||
} catch (ValidationException $e) {
|
} catch (ValidationException $e) {
|
||||||
return Redirect::route('subscribe.subscribe')
|
return Redirect::route('subscribe.subscribe')
|
||||||
->withInput(Binput::all())
|
->withInput(Binput::all())
|
||||||
|
|||||||
@@ -62,6 +62,16 @@ class Subscriber extends Model implements HasPresenter
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scope a query to only include verified subscribers.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Database\Eloquent\Builder
|
||||||
|
*/
|
||||||
|
public function scopeVerified($query)
|
||||||
|
{
|
||||||
|
return $query->whereNotNull('verified_at');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if the subscriber is verified.
|
* Determines if the subscriber is verified.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user