Skip to content

Commit 4cef22b

Browse files
committed
WIP
1 parent 668af18 commit 4cef22b

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -814,14 +814,6 @@ func (q *querier) customRoleEscalationCheck(ctx context.Context, actor rbac.Subj
814814
return nil
815815
}
816816

817-
func (q *querier) GetNotificationSettings(ctx context.Context) (string, error) {
818-
panic("not implemented")
819-
}
820-
821-
func (q *querier) UpsertNotificationSettings(ctx context.Context, value string) error {
822-
panic("not implemented")
823-
}
824-
825817
func (q *querier) AcquireLock(ctx context.Context, id int64) error {
826818
return q.db.AcquireLock(ctx, id)
827819
}
@@ -1488,7 +1480,8 @@ func (q *querier) GetNotificationMessagesByStatus(ctx context.Context, arg datab
14881480
}
14891481

14901482
func (q *querier) GetNotificationsSettings(ctx context.Context) (string, error) {
1491-
panic("not implemented")
1483+
// No authz checks
1484+
return q.db.GetNotificationsSettings(ctx)
14921485
}
14931486

14941487
func (q *querier) GetOAuth2ProviderAppByID(ctx context.Context, id uuid.UUID) (database.OAuth2ProviderApp, error) {
@@ -3700,7 +3693,10 @@ func (q *querier) UpsertLogoURL(ctx context.Context, value string) error {
37003693
}
37013694

37023695
func (q *querier) UpsertNotificationsSettings(ctx context.Context, value string) error {
3703-
panic("not implemented")
3696+
if err := q.authorizeContext(ctx, policy.ActionUpdate, rbac.ResourceDeploymentConfig); err != nil {
3697+
return err
3698+
}
3699+
return q.db.UpsertNotificationsSettings(ctx, value)
37043700
}
37053701

37063702
func (q *querier) UpsertOAuthSigningKey(ctx context.Context, value string) error {

coderd/database/dbmem/dbmem.go

Lines changed: 15 additions & 11 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
applicationName string
203204
logoURL string
204205
appSecurityKey string
@@ -917,14 +918,6 @@ func (q *FakeQuerier) getLatestWorkspaceAppByTemplateIDUserIDSlugNoLock(ctx cont
917918
return database.WorkspaceApp{}, sql.ErrNoRows
918919
}
919920

920-
func (q *FakeQuerier) GetNotificationSettings(ctx context.Context) (string, error) {
921-
panic("not implemented")
922-
}
923-
924-
func (q *FakeQuerier) UpsertNotificationSettings(ctx context.Context, value string) error {
925-
panic("not implemented")
926-
}
927-
928921
func (*FakeQuerier) AcquireLock(_ context.Context, _ int64) error {
929922
return xerrors.New("AcquireLock must only be called within a transaction")
930923
}
@@ -2769,7 +2762,14 @@ func (q *FakeQuerier) GetNotificationMessagesByStatus(_ context.Context, arg dat
27692762
}
27702763

27712764
func (q *FakeQuerier) GetNotificationsSettings(ctx context.Context) (string, error) {
2772-
panic("not implemented")
2765+
q.mutex.RLock()
2766+
defer q.mutex.RUnlock()
2767+
2768+
if q.notificationsSettings == nil {
2769+
return "{}", nil
2770+
}
2771+
2772+
return string(q.notificationsSettings), nil
27732773
}
27742774

27752775
func (q *FakeQuerier) GetOAuth2ProviderAppByID(_ context.Context, id uuid.UUID) (database.OAuth2ProviderApp, error) {
@@ -8725,8 +8725,12 @@ func (q *FakeQuerier) UpsertLogoURL(_ context.Context, data string) error {
87258725
return nil
87268726
}
87278727

8728-
func (q *FakeQuerier) UpsertNotificationsSettings(ctx context.Context, value string) error {
8729-
panic("not implemented")
8728+
func (q *FakeQuerier) UpsertNotificationsSettings(_ context.Context, data string) error {
8729+
q.mutex.RLock()
8730+
defer q.mutex.RUnlock()
8731+
8732+
q.notificationsSettings = []byte(data)
8733+
return nil
87308734
}
87318735

87328736
func (q *FakeQuerier) UpsertOAuthSigningKey(_ context.Context, value string) error {

0 commit comments

Comments
 (0)