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

Commit735d0ef

Browse files
committed
feat: add killswitch for notifications
1 parentac6db5e commit735d0ef

32 files changed

+783
-22
lines changed

‎coderd/apidoc/docs.go

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

‎coderd/apidoc/swagger.json

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

‎coderd/audit/diff.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type Auditable interface {
2020
database.WorkspaceProxy|
2121
database.AuditOAuthConvertState|
2222
database.HealthSettings|
23+
database.NotificationsSettings|
2324
database.OAuth2ProviderApp|
2425
database.OAuth2ProviderAppSecret|
2526
database.CustomRole|

‎coderd/audit/request.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ func ResourceTarget[T Auditable](tgt T) string {
9999
returnstring(typed.ToLoginType)
100100
case database.HealthSettings:
101101
return""// no target?
102+
case database.NotificationsSettings:
103+
return""// no target?
102104
case database.OAuth2ProviderApp:
103105
returntyped.Name
104106
case database.OAuth2ProviderAppSecret:
@@ -142,6 +144,9 @@ func ResourceID[T Auditable](tgt T) uuid.UUID {
142144
case database.HealthSettings:
143145
// Artificial ID for auditing purposes
144146
returntyped.ID
147+
case database.NotificationsSettings:
148+
// Artificial ID for auditing purposes
149+
returntyped.ID
145150
case database.OAuth2ProviderApp:
146151
returntyped.ID
147152
case database.OAuth2ProviderAppSecret:
@@ -183,6 +188,8 @@ func ResourceType[T Auditable](tgt T) database.ResourceType {
183188
returndatabase.ResourceTypeConvertLogin
184189
case database.HealthSettings:
185190
returndatabase.ResourceTypeHealthSettings
191+
case database.NotificationsSettings:
192+
returndatabase.ResourceTypeNotificationsSettings
186193
case database.OAuth2ProviderApp:
187194
returndatabase.ResourceTypeOauth2ProviderApp
188195
case database.OAuth2ProviderAppSecret:
@@ -225,6 +232,9 @@ func ResourceRequiresOrgID[T Auditable]() bool {
225232
case database.HealthSettings:
226233
// Artificial ID for auditing purposes
227234
returnfalse
235+
case database.NotificationsSettings:
236+
// Artificial ID for auditing purposes
237+
returnfalse
228238
case database.OAuth2ProviderApp:
229239
returnfalse
230240
case database.OAuth2ProviderAppSecret:

‎coderd/coderd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,11 @@ func New(options *Options) *API {
12421242
})
12431243
})
12441244
})
1245+
r.Route("/notifications",func(r chi.Router) {
1246+
r.Use(apiKeyMiddleware)
1247+
r.Get("/settings",api.notificationsSettings)
1248+
r.Put("/settings",api.putNotificationsSettings)
1249+
})
12451250
})
12461251

12471252
ifoptions.SwaggerEndpoint {

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,6 +1479,11 @@ func (q *querier) GetNotificationMessagesByStatus(ctx context.Context, arg datab
14791479
returnq.db.GetNotificationMessagesByStatus(ctx,arg)
14801480
}
14811481

1482+
func (q*querier)GetNotificationsSettings(ctx context.Context) (string,error) {
1483+
// No authz checks
1484+
returnq.db.GetNotificationsSettings(ctx)
1485+
}
1486+
14821487
func (q*querier)GetOAuth2ProviderAppByID(ctx context.Context,id uuid.UUID) (database.OAuth2ProviderApp,error) {
14831488
iferr:=q.authorizeContext(ctx,policy.ActionRead,rbac.ResourceOauth2App);err!=nil {
14841489
return database.OAuth2ProviderApp{},err
@@ -3687,6 +3692,13 @@ func (q *querier) UpsertLogoURL(ctx context.Context, value string) error {
36873692
returnq.db.UpsertLogoURL(ctx,value)
36883693
}
36893694

3695+
func (q*querier)UpsertNotificationsSettings(ctx context.Context,valuestring)error {
3696+
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourceDeploymentConfig);err!=nil {
3697+
returnerr
3698+
}
3699+
returnq.db.UpsertNotificationsSettings(ctx,value)
3700+
}
3701+
36903702
func (q*querier)UpsertOAuthSigningKey(ctx context.Context,valuestring)error {
36913703
iferr:=q.authorizeContext(ctx,policy.ActionUpdate,rbac.ResourceSystem);err!=nil {
36923704
returnerr

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,12 @@ func (s *MethodTestSuite) TestSystemFunctions() {
23502350
s.Run("UpsertHealthSettings",s.Subtest(func(db database.Store,check*expects) {
23512351
check.Args("foo").Asserts(rbac.ResourceDeploymentConfig,policy.ActionUpdate)
23522352
}))
2353+
s.Run("GetNotificationsSettings",s.Subtest(func(db database.Store,check*expects) {
2354+
check.Args().Asserts()
2355+
}))
2356+
s.Run("UpsertNotificationsSettings",s.Subtest(func(db database.Store,check*expects) {
2357+
check.Args("foo").Asserts(rbac.ResourceDeploymentConfig,policy.ActionUpdate)
2358+
}))
23532359
s.Run("GetDeploymentWorkspaceAgentStats",s.Subtest(func(db database.Store,check*expects) {
23542360
check.Args(time.Time{}).Asserts()
23552361
}))

‎coderd/database/dbmem/dbmem.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ type data struct {
199199
lastUpdateCheck []byte
200200
announcementBanners []byte
201201
healthSettings []byte
202+
notificationsSettings []byte
202203
applicationNamestring
203204
logoURLstring
204205
appSecurityKeystring
@@ -2760,6 +2761,17 @@ func (q *FakeQuerier) GetNotificationMessagesByStatus(_ context.Context, arg dat
27602761
returnout,nil
27612762
}
27622763

2764+
func (q*FakeQuerier)GetNotificationsSettings(_ context.Context) (string,error) {
2765+
q.mutex.RLock()
2766+
deferq.mutex.RUnlock()
2767+
2768+
ifq.notificationsSettings==nil {
2769+
return"{}",nil
2770+
}
2771+
2772+
returnstring(q.notificationsSettings),nil
2773+
}
2774+
27632775
func (q*FakeQuerier)GetOAuth2ProviderAppByID(_ context.Context,id uuid.UUID) (database.OAuth2ProviderApp,error) {
27642776
q.mutex.Lock()
27652777
deferq.mutex.Unlock()
@@ -8713,6 +8725,14 @@ func (q *FakeQuerier) UpsertLogoURL(_ context.Context, data string) error {
87138725
returnnil
87148726
}
87158727

8728+
func (q*FakeQuerier)UpsertNotificationsSettings(_ context.Context,datastring)error {
8729+
q.mutex.RLock()
8730+
deferq.mutex.RUnlock()
8731+
8732+
q.notificationsSettings= []byte(data)
8733+
returnnil
8734+
}
8735+
87168736
func (q*FakeQuerier)UpsertOAuthSigningKey(_ context.Context,valuestring)error {
87178737
q.mutex.Lock()
87188738
deferq.mutex.Unlock()

‎coderd/database/dbmetrics/dbmetrics.go

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

‎coderd/database/dbmock/dbmock.go

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp