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

Commit1274623

Browse files
committed
move to webpush package
1 parentaa16bbe commit1274623

File tree

7 files changed

+28
-28
lines changed

7 files changed

+28
-28
lines changed

‎cli/server.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ import (
6262
"github.com/coder/wgtunnel/tunnelsdk"
6363

6464
"github.com/coder/coder/v2/coderd/entitlements"
65-
"github.com/coder/coder/v2/coderd/notifications/push"
6665
"github.com/coder/coder/v2/coderd/notifications/reports"
6766
"github.com/coder/coder/v2/coderd/runtimeconfig"
67+
"github.com/coder/coder/v2/coderd/webpush"
6868

6969
"github.com/coder/coder/v2/buildinfo"
7070
"github.com/coder/coder/v2/cli/clilog"
@@ -779,17 +779,17 @@ 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-
webpusher,err:=push.New(ctx,&options.Logger,options.Database)
782+
webpusher,err:=webpush.New(ctx,&options.Logger,options.Database)
783783
iferr!=nil {
784784
options.Logger.Error(ctx,"failed to create web push dispatcher",slog.Error(err))
785785
options.Logger.Warn(ctx,"web push notifications will not work until the VAPID keys are regenerated")
786-
webpusher=&push.NoopWebpusher{
786+
webpusher=&webpush.NoopWebpusher{
787787
Msg:"Web Push notifications are disabled due to a system error. Please contact your Coder administrator.",
788788
}
789789
}
790790
options.WebpushDispatcher=webpusher
791791
}else {
792-
options.WebpushDispatcher=&push.NoopWebpusher{
792+
options.WebpushDispatcher=&webpush.NoopWebpusher{
793793
Msg:"Web Push notifications are an experimental feature and are disabled by default. Enable the 'web-push' experiment to use this feature.",
794794
}
795795
}

‎cli/server_regenerate_vapid_keypair.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"github.com/coder/coder/v2/cli/cliui"
1414
"github.com/coder/coder/v2/coderd/database"
1515
"github.com/coder/coder/v2/coderd/database/awsiamrds"
16-
"github.com/coder/coder/v2/coderd/notifications/push"
16+
"github.com/coder/coder/v2/coderd/webpush"
1717
"github.com/coder/coder/v2/codersdk"
1818
"github.com/coder/serpent"
1919
)
@@ -81,7 +81,7 @@ func (r *RootCmd) newRegenerateVapidKeypairCommand() *serpent.Command {
8181
returnxerrors.Errorf("VAPID keypair regeneration failed: %w",err)
8282
}
8383

84-
if_,_,err:=push.RegenerateVAPIDKeys(ctx,db);err!=nil {
84+
if_,_,err:=webpush.RegenerateVAPIDKeys(ctx,db);err!=nil {
8585
returnxerrors.Errorf("regenerate vapid keypair: %w",err)
8686
}
8787

‎coderd/coderd.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ import (
4444
"github.com/coder/coder/v2/coderd/cryptokeys"
4545
"github.com/coder/coder/v2/coderd/entitlements"
4646
"github.com/coder/coder/v2/coderd/idpsync"
47-
"github.com/coder/coder/v2/coderd/notifications/push"
4847
"github.com/coder/coder/v2/coderd/runtimeconfig"
48+
"github.com/coder/coder/v2/coderd/webpush"
4949

5050
agentproto"github.com/coder/coder/v2/agent/proto"
5151
"github.com/coder/coder/v2/buildinfo"
@@ -263,7 +263,7 @@ type Options struct {
263263
Clock quartz.Clock
264264

265265
// WebpushDispatcher is a way to send notifications over Web Push.
266-
WebpushDispatcherpush.Dispatcher
266+
WebpushDispatcherwebpush.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.WebpushDispatcher,
553+
WebpushDispatcher:options.WebpushDispatcher,
554554
healthCheckGroup:&singleflight.Group[string,*healthsdk.HealthcheckReport]{},
555555
Acquirer:provisionerdserver.NewAcquirer(
556556
ctx,
@@ -585,7 +585,7 @@ func New(options *Options) *API {
585585
WorkspaceProxy:false,
586586
UpgradeMessage:api.DeploymentValues.CLIUpgradeMessage.String(),
587587
DeploymentID:api.DeploymentID,
588-
WebPushPublicKey:api.PushNotifier.PublicKey(),
588+
WebPushPublicKey:api.WebpushDispatcher.PublicKey(),
589589
Telemetry:api.Telemetry.Enabled(),
590590
}
591591
api.SiteHandler=site.New(&site.Options{
@@ -1505,8 +1505,8 @@ type API struct {
15051505
TailnetCoordinator atomic.Pointer[tailnet.Coordinator]
15061506
NetworkTelemetryBatcher*tailnet.NetworkTelemetryBatcher
15071507
TailnetClientService*tailnet.ClientService
1508-
//PushNotifier is a way to sendpushnotifications to users.
1509-
PushNotifier push.Dispatcher
1508+
//WebpushDispatcher is a way to send notifications to users via Web Push.
1509+
WebpushDispatcher webpush.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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ import (
7070
"github.com/coder/coder/v2/coderd/httpmw"
7171
"github.com/coder/coder/v2/coderd/notifications"
7272
"github.com/coder/coder/v2/coderd/notifications/notificationstest"
73-
"github.com/coder/coder/v2/coderd/notifications/push"
7473
"github.com/coder/coder/v2/coderd/rbac"
7574
"github.com/coder/coder/v2/coderd/rbac/policy"
7675
"github.com/coder/coder/v2/coderd/runtimeconfig"
@@ -79,6 +78,7 @@ import (
7978
"github.com/coder/coder/v2/coderd/unhanger"
8079
"github.com/coder/coder/v2/coderd/updatecheck"
8180
"github.com/coder/coder/v2/coderd/util/ptr"
81+
"github.com/coder/coder/v2/coderd/webpush"
8282
"github.com/coder/coder/v2/coderd/workspaceapps"
8383
"github.com/coder/coder/v2/coderd/workspaceapps/appurl"
8484
"github.com/coder/coder/v2/coderd/workspacestats"
@@ -162,7 +162,7 @@ type Options struct {
162162
Logger*slog.Logger
163163
StatsBatcher workspacestats.Batcher
164164

165-
PushNotifier push.Dispatcher
165+
WebpushDispatcherwebpush.Dispatcher
166166
WorkspaceAppsStatsCollectorOptions workspaceapps.StatsCollectorOptions
167167
AllowWorkspaceRenamesbool
168168
NewTickerfunc(duration time.Duration) (<-chan time.Time,func())
@@ -282,13 +282,13 @@ func NewOptions(t testing.TB, options *Options) (func(http.Handler), context.Can
282282
require.NoError(t,err,"insert a deployment id")
283283
}
284284

285-
ifoptions.PushNotifier==nil {
285+
ifoptions.WebpushDispatcher==nil {
286286
// nolint:gocritic // Gets/sets VAPID keys.
287-
pushNotifier,err:=push.New(dbauthz.AsNotifier(context.Background()),options.Logger,options.Database)
287+
pushNotifier,err:=webpush.New(dbauthz.AsNotifier(context.Background()),options.Logger,options.Database)
288288
iferr!=nil {
289289
panic(xerrors.Errorf("failed to create push notifier: %w",err))
290290
}
291-
options.PushNotifier=pushNotifier
291+
options.WebpushDispatcher=pushNotifier
292292
}
293293

294294
ifoptions.DeploymentValues==nil {
@@ -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-
WebpushDispatcher:options.PushNotifier,
544+
WebpushDispatcher:options.WebpushDispatcher,
545545
BaseDERPMap:derpMap,
546546
DERPMapUpdateFrequency:150*time.Millisecond,
547547
CoordinatorResumeTokenProvider:options.CoordinatorResumeTokenProvider,

‎coderd/notifications.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ func (api *API) postUserWebpushSubscription(rw http.ResponseWriter, r *http.Requ
366366
P256dh:req.P256DHKey,
367367
},
368368
},&webpush.Options{
369-
VAPIDPublicKey:api.PushNotifier.PublicKey(),
370-
VAPIDPrivateKey:api.PushNotifier.PrivateKey(),
369+
VAPIDPublicKey:api.WebpushDispatcher.PublicKey(),
370+
VAPIDPrivateKey:api.WebpushDispatcher.PrivateKey(),
371371
})
372372
iferr!=nil {
373373
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
@@ -448,7 +448,7 @@ func (api *API) postUserPushNotificationTest(rw http.ResponseWriter, r *http.Req
448448
ctx:=r.Context()
449449
user:=httpmw.UserParam(r)
450450

451-
iferr:=api.PushNotifier.Dispatch(ctx,user.ID, codersdk.WebpushMessage{
451+
iferr:=api.WebpushDispatcher.Dispatch(ctx,user.ID, codersdk.WebpushMessage{
452452
Title:"It's working!",
453453
Body:"You've subscribed to push notifications.",
454454
});err!=nil {

‎coderd/notifications/push/push.go‎renamed to ‎coderd/webpush/webpush.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packagepush
1+
packagewebpush
22

33
import (
44
"context"

‎coderd/notifications/push/push_test.go‎renamed to ‎coderd/webpush/webpush_test.go‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
packagepush_test
1+
packagewebpush_test
22

33
import (
44
"context"
@@ -16,7 +16,7 @@ import (
1616
"github.com/coder/coder/v2/coderd/database/dbgen"
1717
"github.com/coder/coder/v2/coderd/database/dbtestutil"
1818
"github.com/coder/coder/v2/coderd/database/dbtime"
19-
"github.com/coder/coder/v2/coderd/notifications/push"
19+
"github.com/coder/coder/v2/coderd/webpush"
2020
"github.com/coder/coder/v2/codersdk"
2121
"github.com/coder/coder/v2/testutil"
2222
)
@@ -242,16 +242,16 @@ func TestPush(t *testing.T) {
242242
})
243243
}
244244

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

250250
server:=httptest.NewServer(http.HandlerFunc(handlerFunc))
251251
t.Cleanup(server.Close)
252252

253-
manager,err:=push.New(ctx,&logger,db)
254-
require.NoError(t,err,"Failed to createpush manager")
253+
manager,err:=webpush.New(ctx,&logger,db)
254+
require.NoError(t,err,"Failed to createwebpush manager")
255255

256256
returnmanager,db,server.URL
257257
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp