mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: graduate web-push from experiment to always-on (#24310)
* Removes experiment `web-push`.
* Falls back to NoopWebpusher in case of error
* Checks browser capability in FE
* Adds note to agents getting-started docs regarding webpush without TLS
> 🤖
This commit is contained in:
+6
-19
@@ -843,27 +843,14 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
|
||||
}
|
||||
|
||||
// Manage push notifications.
|
||||
experiments := coderd.ReadExperiments(options.Logger, options.DeploymentValues.Experiments.Value())
|
||||
if experiments.Enabled(codersdk.ExperimentWebPush) || buildinfo.IsDev() {
|
||||
if !strings.HasPrefix(options.AccessURL.String(), "https://") {
|
||||
options.Logger.Warn(ctx, "access URL is not HTTPS, so web push notifications may not work on some browsers", slog.F("access_url", options.AccessURL.String()))
|
||||
}
|
||||
webpusher, err := webpush.New(ctx, ptr.Ref(options.Logger.Named("webpush")), options.Database, options.AccessURL.String())
|
||||
if err != nil {
|
||||
options.Logger.Error(ctx, "failed to create web push dispatcher", slog.Error(err))
|
||||
options.Logger.Warn(ctx, "web push notifications will not work until the VAPID keys are regenerated")
|
||||
webpusher = &webpush.NoopWebpusher{
|
||||
Msg: "Web Push notifications are disabled due to a system error. Please contact your Coder administrator.",
|
||||
}
|
||||
}
|
||||
options.WebPushDispatcher = webpusher
|
||||
} else {
|
||||
options.WebPushDispatcher = &webpush.NoopWebpusher{
|
||||
// Users will likely not see this message as the endpoints return 404
|
||||
// if not enabled. Just in case...
|
||||
Msg: "Web Push notifications are an experimental feature and are disabled by default. Enable the 'web-push' experiment to use this feature.",
|
||||
webpusher, err := webpush.New(ctx, ptr.Ref(options.Logger.Named("webpush")), options.Database, options.AccessURL.String())
|
||||
if err != nil {
|
||||
options.Logger.Error(ctx, "failed to create web push dispatcher", slog.Error(err))
|
||||
webpusher = &webpush.NoopWebpusher{
|
||||
Msg: "Web Push notifications are disabled due to a system error. Please contact your Coder administrator.",
|
||||
}
|
||||
}
|
||||
options.WebPushDispatcher = webpusher
|
||||
|
||||
githubOAuth2ConfigParams, err := getGithubOAuth2ConfigParams(ctx, options.Database, vals)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user