Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27a045f

Browse files
committed
notification -> webpush
1 parent5d37dbe commit27a045f

File tree

14 files changed

+77
-77
lines changed

14 files changed

+77
-77
lines changed

‎cli/server.go‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -779,18 +779,18 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
779779
// Manage push notifications.
780780
experiments:=coderd.ReadExperiments(options.Logger,options.DeploymentValues.Experiments.Value())
781781
ifexperiments.Enabled(codersdk.ExperimentWebPush) {
782-
pushNotifier,err:=push.New(ctx,&options.Logger,options.Database)
782+
webpusher,err:=push.New(ctx,&options.Logger,options.Database)
783783
iferr!=nil {
784-
options.Logger.Error(ctx,"failed to create pushnotifier",slog.Error(err))
785-
options.Logger.Warn(ctx,"push notifications will not work until the VAPID keys are regenerated")
786-
pushNotifier=&push.NoopNotifier{
787-
Msg:"Push notifications are disabled due to a system error. Please contact your Coder administrator.",
784+
options.Logger.Error(ctx,"failed to createwebpushdispatcher",slog.Error(err))
785+
options.Logger.Warn(ctx,"webpush notifications will not work until the VAPID keys are regenerated")
786+
webpusher=&push.NoopWebpusher{
787+
Msg:"WebPush notifications are disabled due to a system error. Please contact your Coder administrator.",
788788
}
789789
}
790-
options.PushNotifier=pushNotifier
790+
options.WebpushDispatcher=webpusher
791791
}else {
792-
options.PushNotifier=&push.NoopNotifier{
793-
Msg:"Push notifications are disabled. Enable the 'web-push' experiment to use this feature.",
792+
options.WebpushDispatcher=&push.NoopWebpusher{
793+
Msg:"WebPush notifications arean experimental feature and aredisabled by default. Enable the 'web-push' experiment to use this feature.",
794794
}
795795
}
796796

‎cli/server_regenerate_vapid_keypair.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (r *RootCmd) newRegenerateVapidKeypairCommand() *serpent.Command {
2525
)
2626
regenerateVapidKeypairCommand:=&serpent.Command{
2727
Use:"regenerate-vapid-keypair",
28-
Short:"Regenerate the VAPID keypair used for push notifications.",
28+
Short:"Regenerate the VAPID keypair used forwebpush notifications.",
2929
Hidden:true,// Hide this command as it's an experimental feature
3030
Handler:func(inv*serpent.Invocation)error {
3131
var (
@@ -71,7 +71,7 @@ func (r *RootCmd) newRegenerateVapidKeypairCommand() *serpent.Command {
7171

7272
// Confirm that the user really wants to regenerate the VAPID keypair.
7373
cliui.Infof(inv.Stdout,"Regenerating VAPID keypair...")
74-
cliui.Infof(inv.Stdout,"This will delete all existingpush notification subscriptions.")
74+
cliui.Infof(inv.Stdout,"This will delete all existingwebpush subscriptions.")
7575
cliui.Infof(inv.Stdout,"Are you sure you want to continue? (y/N)")
7676

7777
ifresp,err:=cliui.Prompt(inv, cliui.PromptOptions{

‎coderd/apidoc/docs.go‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/apidoc/swagger.json‎

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎coderd/coderd.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,8 @@ type Options struct {
262262
OIDCConvertKeyCache cryptokeys.SigningKeycache
263263
Clock quartz.Clock
264264

265-
//PushNotifier is a way to sendpushnotificationsto users.
266-
PushNotifier push.NotificationDispatcher
265+
//WebpushDispatcher is a way to send notificationsover Web Push.
266+
WebpushDispatcher push.Dispatcher
267267
}
268268

269269
// @title Coder API
@@ -550,7 +550,7 @@ func New(options *Options) *API {
550550
UserQuietHoursScheduleStore:options.UserQuietHoursScheduleStore,
551551
AccessControlStore:options.AccessControlStore,
552552
Experiments:experiments,
553-
PushNotifier:options.PushNotifier,
553+
PushNotifier:options.WebpushDispatcher,
554554
healthCheckGroup:&singleflight.Group[string,*healthsdk.HealthcheckReport]{},
555555
Acquirer:provisionerdserver.NewAcquirer(
556556
ctx,
@@ -1506,7 +1506,7 @@ type API struct {
15061506
NetworkTelemetryBatcher*tailnet.NetworkTelemetryBatcher
15071507
TailnetClientService*tailnet.ClientService
15081508
// PushNotifier is a way to send push notifications to users.
1509-
PushNotifier push.NotificationDispatcher
1509+
PushNotifier push.Dispatcher
15101510
QuotaCommitter atomic.Pointer[proto.QuotaCommitter]
15111511
AppearanceFetcher atomic.Pointer[appearance.Fetcher]
15121512
// WorkspaceProxyHostsFn returns the hosts of healthy workspace proxies

‎coderd/coderdtest/coderdtest.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ type Options struct {
162162
Logger*slog.Logger
163163
StatsBatcher workspacestats.Batcher
164164

165-
PushNotifier push.NotificationDispatcher
165+
PushNotifier push.Dispatcher
166166
WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions
167167
AllowWorkspaceRenamesbool
168168
NewTickerfunc(duration time.Duration) (<-chan time.Time,func())
@@ -541,7 +541,7 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
541541
TrialGenerator:options.TrialGenerator,
542542
RefreshEntitlements:options.RefreshEntitlements,
543543
TailnetCoordinator:options.Coordinator,
544-
PushNotifier:options.PushNotifier,
544+
WebpushDispatcher:options.PushNotifier,
545545
BaseDERPMap:derpMap,
546546
DERPMapUpdateFrequency:150*time.Millisecond,
547547
CoordinatorResumeTokenProvider:options.CoordinatorResumeTokenProvider,

‎coderd/notifications.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,8 @@ func (api *API) putUserNotificationPreferences(rw http.ResponseWriter, r *http.R
327327
httpapi.Write(ctx,rw,http.StatusOK,out)
328328
}
329329

330-
// @Summary Create userpush notification subscription
331-
// @ID create-user-push-notification-subscription
330+
// @Summary Create userwebpush notification subscription
331+
// @ID create-user-webpush-notification-subscription
332332
// @Security CoderSessionToken
333333
// @Accept json
334334
// @Tags Notifications
@@ -404,8 +404,8 @@ func (api *API) postUserWebpushSubscription(rw http.ResponseWriter, r *http.Requ
404404
rw.WriteHeader(http.StatusNoContent)
405405
}
406406

407-
// @Summary Delete userpush notification subscription
408-
// @ID delete-user-push-notification-subscription
407+
// @Summary Delete userwebpush notification subscription
408+
// @ID delete-user-webpush-notification-subscription
409409
// @Security CoderSessionToken
410410
// @Accept json
411411
// @Tags Notifications

‎coderd/notifications/push/push.go‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ import (
2121
"github.com/coder/coder/v2/codersdk"
2222
)
2323

24-
//NotificationDispatcher is an interface that can be used to dispatch
25-
// push notifications.
26-
typeNotificationDispatcherinterface {
24+
//Dispatcher is an interface that can be used to dispatch
25+
// push notifications over Web Push.
26+
typeDispatcherinterface {
2727
Dispatch(ctx context.Context,userID uuid.UUID,notification codersdk.WebpushMessage)error
2828
PublicKey()string
2929
PrivateKey()string
3030
}
3131

32-
// New creates a newpush managerto dispatchpushnotifications.
32+
// New creates a newDispatcherto dispatch notifications via Web Push.
3333
//
3434
// This is *not* integrated into the enqueue system unfortunately.
3535
// That's because the notifications system has a enqueue system,
3636
// and push notifications at time of implementation are being used
3737
// for updates inside of a workspace, which we want to be immediate.
3838
//
3939
// See: https://github.com/coder/internal/issues/528
40-
funcNew(ctx context.Context,log*slog.Logger,db database.Store) (NotificationDispatcher,error) {
40+
funcNew(ctx context.Context,log*slog.Logger,db database.Store) (Dispatcher,error) {
4141
keys,err:=db.GetWebpushVAPIDKeys(ctx)
4242
iferr!=nil {
4343
if!errors.Is(err,sql.ErrNoRows) {
@@ -57,23 +57,23 @@ func New(ctx context.Context, log *slog.Logger, db database.Store) (Notification
5757
keys.VapidPrivateKey=newPrivateKey
5858
}
5959

60-
return&Notifier{
60+
return&Webpusher{
6161
store:db,
6262
log:log,
6363
VAPIDPublicKey:keys.VapidPublicKey,
6464
VAPIDPrivateKey:keys.VapidPrivateKey,
6565
},nil
6666
}
6767

68-
typeNotifierstruct {
68+
typeWebpusherstruct {
6969
store database.Store
7070
log*slog.Logger
7171

7272
VAPIDPublicKeystring
7373
VAPIDPrivateKeystring
7474
}
7575

76-
func (n*Notifier)Dispatch(ctx context.Context,userID uuid.UUID,notification codersdk.WebpushMessage)error {
76+
func (n*Webpusher)Dispatch(ctx context.Context,userID uuid.UUID,notification codersdk.WebpushMessage)error {
7777
subscriptions,err:=n.store.GetWebpushSubscriptionsByUserID(ctx,userID)
7878
iferr!=nil {
7979
returnxerrors.Errorf("get notification push subscriptions by user ID: %w",err)
@@ -122,7 +122,7 @@ func (n *Notifier) Dispatch(ctx context.Context, userID uuid.UUID, notification
122122
ifresp.StatusCode>http.StatusAccepted {
123123
// It's likely the subscription failed to deliver for some reason.
124124
body,_:=io.ReadAll(resp.Body)
125-
returnxerrors.Errorf("pushnotification failed with status code %d: %s",resp.StatusCode,string(body))
125+
returnxerrors.Errorf("webpushdispatch failed with status code %d: %s",resp.StatusCode,string(body))
126126
}
127127

128128
returnnil
@@ -145,30 +145,30 @@ func (n *Notifier) Dispatch(ctx context.Context, userID uuid.UUID, notification
145145
returnnil
146146
}
147147

148-
func (n*Notifier)PublicKey()string {
148+
func (n*Webpusher)PublicKey()string {
149149
returnn.VAPIDPublicKey
150150
}
151151

152-
func (n*Notifier)PrivateKey()string {
152+
func (n*Webpusher)PrivateKey()string {
153153
returnn.VAPIDPrivateKey
154154
}
155155

156-
//NoopNotifier is aNotifier that does nothing except return an error.
156+
//NoopWebpusher is aDispatcher that does nothing except return an error.
157157
// This is returned when push notifications are disabled, or if there was an
158158
// error generating the VAPID keys.
159-
typeNoopNotifierstruct {
159+
typeNoopWebpusherstruct {
160160
Msgstring
161161
}
162162

163-
func (n*NoopNotifier)Dispatch(context.Context, uuid.UUID, codersdk.WebpushMessage)error {
163+
func (n*NoopWebpusher)Dispatch(context.Context, uuid.UUID, codersdk.WebpushMessage)error {
164164
returnxerrors.New(n.Msg)
165165
}
166166

167-
func (*NoopNotifier)PublicKey()string {
167+
func (*NoopWebpusher)PublicKey()string {
168168
return""
169169
}
170170

171-
func (*NoopNotifier)PrivateKey()string {
171+
func (*NoopWebpusher)PrivateKey()string {
172172
return""
173173
}
174174

‎coderd/notifications/push/push_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ func TestPush(t *testing.T) {
243243
}
244244

245245
// setupPushTest creates a common test setup for push notification tests
246-
funcsetupPushTest(ctx context.Context,t*testing.T,handlerFuncfunc(w http.ResponseWriter,r*http.Request)) (push.NotificationDispatcher, database.Store,string) {
246+
funcsetupPushTest(ctx context.Context,t*testing.T,handlerFuncfunc(w http.ResponseWriter,r*http.Request)) (push.Dispatcher, database.Store,string) {
247247
logger:=slogtest.Make(t,&slogtest.Options{IgnoreErrors:true}).Leveled(slog.LevelDebug)
248248
db,_:=dbtestutil.NewDB(t)
249249

‎coderd/notifications_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func TestNotificationTest(t *testing.T) {
379379
}
380380

381381
const (
382-
// These are valid keys for apush notification subscription.
382+
// These are valid keys for aweb push subscription.
383383
// DO NOT REUSE THESE IN ANY REAL CODE.
384384
validEndpointAuthKey="zqbxT6JKstKSY9JKibZLSQ=="
385385
validEndpointP256dhKey="BNNL5ZaTfK81qhXOx23+wewhigUeFb632jN6LvRWCFH1ubQr77FE/9qV1FuojuRmHP42zmf34rXgW80OvUVDgTk="
@@ -413,7 +413,7 @@ func TestPushNotificationSubscription(t *testing.T) {
413413
require.True(t,<-handlerCalled,"handler should have been called")
414414

415415
err=memberClient.PostTestWebpushMessage(ctx)
416-
require.NoError(t,err,"test push notification")
416+
require.NoError(t,err,"testwebpush notification")
417417
require.True(t,<-handlerCalled,"handler should have been called again")
418418

419419
err=memberClient.DeleteWebpushSubscription(ctx,"me", codersdk.DeleteWebpushSubscription{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp