Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues with Slack notifications, missing/wrong variables #3422

Closed
wants to merge 12 commits into from
4 changes: 0 additions & 4 deletions app/Http/Middleware/SubscribersConfigured.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ public function __construct(Repository $config)
*/
public function handle(Request $request, Closure $next)
{
if (!$this->config->get('setting.enable_subscribers')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have we removed this condition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have we removed this condition?

The subscription page must be manageable, despite the setting "Allow to subscribe". Admin should always be able to configure the subscribers and manage their subscriptions, etc.

You can not have this setting enabled or not based on "if the user is allowed to subscribe or not feature"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then the condition should check for an active admin user, then?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is done at the auth module ( outside of the scope for this commit)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is handled in app/Http/Kernel.php
@jbrooksuk

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If subscriptions aren't enabled and you're not an admin, then you shouldn't be able to see the subscription page, so as far as I can tell, the middleware is required.

return cachet_redirect('status-page');
}

return $next($request);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function toSlack($notifiable)

return (new SlackMessage())
->$status()
->content(trans('notifications.component.status_update.slack.subject'))
->content(trans('notifications.component.status_update.slack.title'))
->attachment(function ($attachment) use ($content, $notifiable) {
$attachment->title($content, cachet_route('status-page'))
->fields(array_filter([
Expand Down
5 changes: 2 additions & 3 deletions app/Notifications/Incident/NewIncidentNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,12 @@ public function toSlack($notifiable)
->$status()
->content($content)
->attachment(function ($attachment) use ($notifiable) {
$attachment->title(trans('notifications.incident.new.slack.title', [$this->incident->name]))
$attachment->title(trans('notifications.incident.new.slack.title', ['name' => $this->incident->name]))
->timestamp($this->incident->getWrappedObject()->occurred_at)
->fields(array_filter([
'ID' => "#{$this->incident->id}",
'Link' => $this->incident->permalink,
]))
->footer(trans('cachet.subscriber.unsubscribe', ['link' => cachet_route('subscribe.unsubscribe', $notifiable->verify_code)]));
]));
});
}
}
3 changes: 1 addition & 2 deletions app/Notifications/Schedule/NewScheduleNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ public function toSlack($notifiable)
->fields(array_filter([
'ID' => "#{$this->schedule->id}",
'Status' => $this->schedule->human_status,
]))
->footer(trans('cachet.subscriber.unsubscribe', ['link' => cachet_route('subscribe.unsubscribe', $notifiable->verify_code)]));
]));
});
}
}
7 changes: 2 additions & 5 deletions resources/views/dashboard/subscribers/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<span class="uppercase">
<i class="ion ion-ios-email-outline"></i> {{ trans('dashboard.subscribers.subscribers') }}
</span>
@if($currentUser->isAdmin && $enableSubscribers)
@if($currentUser->isAdmin)
<a class="btn btn-md btn-success pull-right" href="{{ cachet_route('dashboard.subscribers.create') }}">
{{ trans('dashboard.subscribers.add.title') }}
</a>
Expand All @@ -19,11 +19,7 @@
<div class="row">
<div class="col-sm-12">
<p class="lead">
@if($enableSubscribers)
{{ trans('dashboard.subscribers.description') }}
@else
{{ trans('dashboard.subscribers.description_disabled') }}
@endif
</p>

<div class="striped-list">
Expand Down Expand Up @@ -51,6 +47,7 @@
@endif
</div>
<div class="col-xs-3 text-right">
<a href="{{ cachet_route('subscribe.manage', $subscriber->verify_code) }}" target="_blank" class="btn btn-success">{{ trans('forms.edit') }}</a>
<a href="{{ cachet_route('dashboard.subscribers.delete', [$subscriber->id], 'delete') }}" class="btn btn-danger confirm-action" data-method='DELETE'>{{ trans('forms.delete') }}</a>
</div>
</div>
Expand Down