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

Commit3bb9c57

Browse files
committed
rename inbox notifications
1 parentd02609f commit3bb9c57

23 files changed

+236
-207
lines changed

‎coderd/apidoc/docs.go

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

‎coderd/apidoc/swagger.json

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

‎coderd/database/dbauthz/dbauthz.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,12 +1417,12 @@ func (q *querier) FavoriteWorkspace(ctx context.Context, id uuid.UUID) error {
14171417
returnupdate(q.log,q.auth,fetch,q.db.FavoriteWorkspace)(ctx,id)
14181418
}
14191419

1420-
func (q*querier)FetchInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
1420+
func (q*querier)FetchInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.InboxNotification,error) {
14211421
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserID)(ctx,userID)
14221422
}
14231423

1424-
func (q*querier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargets(ctx context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
1425-
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserIDAndTemplateIDAndTargets)(ctx,arg)
1424+
func (q*querier)FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargets(ctx context.Context,arg database.FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams) ([]database.InboxNotification,error) {
1425+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargets)(ctx,arg)
14261426
}
14271427

14281428
func (q*querier)FetchMemoryResourceMonitorsByAgentID(ctx context.Context,agentID uuid.UUID) (database.WorkspaceAgentMemoryResourceMonitor,error) {
@@ -1446,12 +1446,12 @@ func (q *querier) FetchNewMessageMetadata(ctx context.Context, arg database.Fetc
14461446
returnq.db.FetchNewMessageMetadata(ctx,arg)
14471447
}
14481448

1449-
func (q*querier)FetchUnreadInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
1449+
func (q*querier)FetchUnreadInboxNotificationsByUserID(ctx context.Context,userID uuid.UUID) ([]database.InboxNotification,error) {
14501450
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserID)(ctx,userID)
14511451
}
14521452

1453-
func (q*querier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets(ctx context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
1454-
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets)(ctx,arg)
1453+
func (q*querier)FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargets(ctx context.Context,arg database.FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams) ([]database.InboxNotification,error) {
1454+
returnfetchWithPostFilter(q.auth,policy.ActionRead,q.db.FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargets)(ctx,arg)
14551455
}
14561456

14571457
func (q*querier)FetchVolumesResourceMonitorsByAgentID(ctx context.Context,agentID uuid.UUID) ([]database.WorkspaceAgentVolumeResourceMonitor,error) {
@@ -1766,7 +1766,7 @@ func (q *querier) GetHungProvisionerJobs(ctx context.Context, hungSince time.Tim
17661766
returnq.db.GetHungProvisionerJobs(ctx,hungSince)
17671767
}
17681768

1769-
func (q*querier)GetInboxNotificationByID(ctx context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
1769+
func (q*querier)GetInboxNotificationByID(ctx context.Context,id uuid.UUID) (database.InboxNotification,error) {
17701770
returnfetchWithAction(q.log,q.auth,policy.ActionRead,q.db.GetInboxNotificationByID)(ctx,id)
17711771
}
17721772

@@ -3097,8 +3097,8 @@ func (q *querier) InsertGroupMember(ctx context.Context, arg database.InsertGrou
30973097
returnupdate(q.log,q.auth,fetch,q.db.InsertGroupMember)(ctx,arg)
30983098
}
30993099

3100-
func (q*querier)InsertInboxNotification(ctx context.Context,arg database.InsertInboxNotificationParams) (database.NotificationsInbox,error) {
3101-
returninsert(q.log,q.auth,rbac.ResourceNotificationInbox.WithOwner(arg.UserID.String()),q.db.InsertInboxNotification)(ctx,arg)
3100+
func (q*querier)InsertInboxNotification(ctx context.Context,arg database.InsertInboxNotificationParams) (database.InboxNotification,error) {
3101+
returninsert(q.log,q.auth,rbac.ResourceInboxNotification.WithOwner(arg.UserID.String()),q.db.InsertInboxNotification)(ctx,arg)
31023102
}
31033103

31043104
func (q*querier)InsertLicense(ctx context.Context,arg database.InsertLicenseParams) (database.License,error) {
@@ -3589,7 +3589,7 @@ func (q *querier) RevokeDBCryptKey(ctx context.Context, activeKeyDigest string)
35893589
}
35903590

35913591
func (q*querier)SetInboxNotificationAsRead(ctx context.Context,args database.SetInboxNotificationAsReadParams)error {
3592-
fetchFunc:=func(ctx context.Context,args database.SetInboxNotificationAsReadParams) (database.NotificationsInbox,error) {
3592+
fetchFunc:=func(ctx context.Context,args database.SetInboxNotificationAsReadParams) (database.InboxNotification,error) {
35933593
returnq.db.GetInboxNotificationByID(ctx,args.ID)
35943594
}
35953595

‎coderd/database/dbauthz/dbauthz_test.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4497,7 +4497,7 @@ func (s *MethodTestSuite) TestNotifications() {
44974497
Icon:"test icon",
44984498
})
44994499

4500-
check.Args(u.ID).Asserts(rbac.ResourceNotificationInbox.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.NotificationsInbox{notif})
4500+
check.Args(u.ID).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.InboxNotification{notif})
45014501
}))
45024502

45034503
s.Run("FetchInboxNotificationsByUserID",s.Subtest(func(db database.Store,check*expects) {
@@ -4519,10 +4519,10 @@ func (s *MethodTestSuite) TestNotifications() {
45194519
Icon:"test icon",
45204520
})
45214521

4522-
check.Args(u.ID).Asserts(rbac.ResourceNotificationInbox.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.NotificationsInbox{notif})
4522+
check.Args(u.ID).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.InboxNotification{notif})
45234523
}))
45244524

4525-
s.Run("FetchInboxNotificationsByUserIDAndTemplateIDAndTargets",s.Subtest(func(db database.Store,check*expects) {
4525+
s.Run("FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargets",s.Subtest(func(db database.Store,check*expects) {
45264526
u:=dbgen.User(s.T(),db, database.User{})
45274527
o:=dbgen.Organization(s.T(),db, database.Organization{})
45284528
tpl:=dbgen.Template(s.T(),db, database.Template{
@@ -4544,14 +4544,14 @@ func (s *MethodTestSuite) TestNotifications() {
45444544
Icon:"test icon",
45454545
})
45464546

4547-
check.Args(database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetsParams{
4548-
UserID:u.ID,
4549-
TemplateID:tpl.ID,
4550-
Targets:[]uuid.UUID{u.ID},
4551-
}).Asserts(rbac.ResourceNotificationInbox.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.NotificationsInbox{notif})
4547+
check.Args(database.FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams{
4548+
UserID:u.ID,
4549+
Templates: []uuid.UUID{tpl.ID},
4550+
Targets: []uuid.UUID{u.ID},
4551+
}).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.InboxNotification{notif})
45524552
}))
45534553

4554-
s.Run("FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets",s.Subtest(func(db database.Store,check*expects) {
4554+
s.Run("FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargets",s.Subtest(func(db database.Store,check*expects) {
45554555
u:=dbgen.User(s.T(),db, database.User{})
45564556
o:=dbgen.Organization(s.T(),db, database.Organization{})
45574557
tpl:=dbgen.Template(s.T(),db, database.Template{
@@ -4573,11 +4573,11 @@ func (s *MethodTestSuite) TestNotifications() {
45734573
Icon:"test icon",
45744574
})
45754575

4576-
check.Args(database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetsParams{
4577-
UserID:u.ID,
4578-
TemplateID:tpl.ID,
4579-
Targets:[]uuid.UUID{u.ID},
4580-
}).Asserts(rbac.ResourceNotificationInbox.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.NotificationsInbox{notif})
4576+
check.Args(database.FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams{
4577+
UserID:u.ID,
4578+
Templates: []uuid.UUID{tpl.ID},
4579+
Targets: []uuid.UUID{u.ID},
4580+
}).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns([]database.InboxNotification{notif})
45814581
}))
45824582

45834583
s.Run("GetInboxNotificationByID",s.Subtest(func(db database.Store,check*expects) {
@@ -4602,12 +4602,12 @@ func (s *MethodTestSuite) TestNotifications() {
46024602
Icon:"test icon",
46034603
})
46044604

4605-
check.Args(notifID).Asserts(rbac.ResourceNotificationInbox.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns(notif)
4605+
check.Args(notifID).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionRead).Returns(notif)
46064606
}))
46074607

46084608
s.Run("InsertInboxNotification",s.Subtest(func(_ database.Store,check*expects) {
46094609
owner:= uuid.UUID{}
4610-
check.Args(database.InsertInboxNotificationParams{}).Asserts(rbac.ResourceNotificationInbox.WithOwner(owner.String()),policy.ActionCreate)
4610+
check.Args(database.InsertInboxNotificationParams{}).Asserts(rbac.ResourceInboxNotification.WithOwner(owner.String()),policy.ActionCreate)
46114611
}))
46124612

46134613
s.Run("SetInboxNotificationAsRead",s.Subtest(func(db database.Store,check*expects) {
@@ -4638,7 +4638,7 @@ func (s *MethodTestSuite) TestNotifications() {
46384638
check.Args(database.SetInboxNotificationAsReadParams{
46394639
ID:notifID,
46404640
ReadAt: sql.NullTime{Time:readAt,Valid:true},
4641-
}).Asserts(rbac.ResourceNotificationInbox.WithID(notifID).WithOwner(u.ID.String()),policy.ActionUpdate)
4641+
}).Asserts(rbac.ResourceInboxNotification.WithID(notifID).WithOwner(u.ID.String()),policy.ActionUpdate)
46424642
}))
46434643
}
46444644

‎coderd/database/dbgen/dbgen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ func OrganizationMember(t testing.TB, db database.Store, orig database.Organizat
450450
returnmem
451451
}
452452

453-
funcNotificationInbox(t testing.TB,db database.Store,orig database.InsertInboxNotificationParams) database.NotificationsInbox {
453+
funcNotificationInbox(t testing.TB,db database.Store,orig database.InsertInboxNotificationParams) database.InboxNotification {
454454
notification,err:=db.InsertInboxNotification(genCtx, database.InsertInboxNotificationParams{
455455
ID:takeFirst(orig.ID,uuid.New()),
456456
UserID:takeFirst(orig.UserID,uuid.New()),

‎coderd/database/dbmem/dbmem.go

Lines changed: 48 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func New() database.Store {
6767
gitSSHKey:make([]database.GitSSHKey,0),
6868
notificationMessages:make([]database.NotificationMessage,0),
6969
notificationPreferences:make([]database.NotificationPreference,0),
70-
notificationsInbox:make([]database.NotificationsInbox,0),
70+
InboxNotification:make([]database.InboxNotification,0),
7171
parameterSchemas:make([]database.ParameterSchema,0),
7272
provisionerDaemons:make([]database.ProvisionerDaemon,0),
7373
provisionerKeys:make([]database.ProvisionerKey,0),
@@ -207,7 +207,7 @@ type data struct {
207207
notificationMessages []database.NotificationMessage
208208
notificationPreferences []database.NotificationPreference
209209
notificationReportGeneratorLogs []database.NotificationReportGeneratorLog
210-
notificationsInbox []database.NotificationsInbox
210+
InboxNotification[]database.InboxNotification
211211
oauth2ProviderApps []database.OAuth2ProviderApp
212212
oauth2ProviderAppSecrets []database.OAuth2ProviderAppSecret
213213
oauth2ProviderAppCodes []database.OAuth2ProviderAppCode
@@ -2365,12 +2365,12 @@ func (q *FakeQuerier) FavoriteWorkspace(_ context.Context, arg uuid.UUID) error
23652365
returnnil
23662366
}
23672367

2368-
func (q*FakeQuerier)FetchInboxNotificationsByUserID(_ context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
2368+
func (q*FakeQuerier)FetchInboxNotificationsByUserID(_ context.Context,userID uuid.UUID) ([]database.InboxNotification,error) {
23692369
q.mutex.RLock()
23702370
deferq.mutex.RUnlock()
23712371

2372-
notifications:=make([]database.NotificationsInbox,0)
2373-
for_,notification:=rangeq.notificationsInbox {
2372+
notifications:=make([]database.InboxNotification,0)
2373+
for_,notification:=rangeq.InboxNotification {
23742374
ifnotification.UserID==userID {
23752375
notifications=append(notifications,notification)
23762376
}
@@ -2379,13 +2379,24 @@ func (q *FakeQuerier) FetchInboxNotificationsByUserID(_ context.Context, userID
23792379
returnnotifications,nil
23802380
}
23812381

2382-
func (q*FakeQuerier)FetchInboxNotificationsByUserIDAndTemplateIDAndTargets(_ context.Context,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
2382+
func (q*FakeQuerier)FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargets(_ context.Context,arg database.FetchInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams) ([]database.InboxNotification,error) {
23832383
q.mutex.RLock()
23842384
deferq.mutex.RUnlock()
23852385

2386-
notifications:=make([]database.NotificationsInbox,0)
2387-
for_,notification:=rangeq.notificationsInbox {
2388-
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID {
2386+
notifications:=make([]database.InboxNotification,0)
2387+
for_,notification:=rangeq.InboxNotification {
2388+
ifnotification.UserID==arg.UserID {
2389+
for_,template:=rangearg.Templates {
2390+
templateFound:=false
2391+
ifnotification.TemplateID==template {
2392+
templateFound=true
2393+
}
2394+
2395+
if!templateFound {
2396+
continue
2397+
}
2398+
}
2399+
23892400
for_,target:=rangearg.Targets {
23902401
isFound:=false
23912402
for_,insertedTarget:=rangenotification.Targets {
@@ -2449,12 +2460,12 @@ func (q *FakeQuerier) FetchNewMessageMetadata(_ context.Context, arg database.Fe
24492460
},nil
24502461
}
24512462

2452-
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserID(_ context.Context,userID uuid.UUID) ([]database.NotificationsInbox,error) {
2463+
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserID(_ context.Context,userID uuid.UUID) ([]database.InboxNotification,error) {
24532464
q.mutex.RLock()
24542465
deferq.mutex.RUnlock()
24552466

2456-
notifications:=make([]database.NotificationsInbox,0)
2457-
for_,notification:=rangeq.notificationsInbox {
2467+
notifications:=make([]database.InboxNotification,0)
2468+
for_,notification:=rangeq.InboxNotification {
24582469
ifnotification.UserID==userID&&!notification.ReadAt.Valid {
24592470
notifications=append(notifications,notification)
24602471
}
@@ -2463,13 +2474,24 @@ func (q *FakeQuerier) FetchUnreadInboxNotificationsByUserID(_ context.Context, u
24632474
returnnotifications,nil
24642475
}
24652476

2466-
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargets(_ context.Context,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetsParams) ([]database.NotificationsInbox,error) {
2477+
func (q*FakeQuerier)FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargets(_ context.Context,arg database.FetchUnreadInboxNotificationsByUserIDFilteredByTemplatesAndTargetsParams) ([]database.InboxNotification,error) {
24672478
q.mutex.RLock()
24682479
deferq.mutex.RUnlock()
24692480

2470-
notifications:=make([]database.NotificationsInbox,0)
2471-
for_,notification:=rangeq.notificationsInbox {
2472-
ifnotification.UserID==arg.UserID&&notification.TemplateID==arg.TemplateID&&!notification.ReadAt.Valid {
2481+
notifications:=make([]database.InboxNotification,0)
2482+
for_,notification:=rangeq.InboxNotification {
2483+
ifnotification.UserID==arg.UserID&&!notification.ReadAt.Valid {
2484+
for_,template:=rangearg.Templates {
2485+
templateFound:=false
2486+
ifnotification.TemplateID==template {
2487+
templateFound=true
2488+
}
2489+
2490+
if!templateFound {
2491+
continue
2492+
}
2493+
}
2494+
24732495
for_,target:=rangearg.Targets {
24742496
isFound:=false
24752497
for_,insertedTarget:=rangenotification.Targets {
@@ -3418,17 +3440,17 @@ func (q *FakeQuerier) GetHungProvisionerJobs(_ context.Context, hungSince time.T
34183440
returnhungJobs,nil
34193441
}
34203442

3421-
func (q*FakeQuerier)GetInboxNotificationByID(_ context.Context,id uuid.UUID) (database.NotificationsInbox,error) {
3443+
func (q*FakeQuerier)GetInboxNotificationByID(_ context.Context,id uuid.UUID) (database.InboxNotification,error) {
34223444
q.mutex.RLock()
34233445
deferq.mutex.RUnlock()
34243446

3425-
for_,notification:=rangeq.notificationsInbox {
3447+
for_,notification:=rangeq.InboxNotification {
34263448
ifnotification.ID==id {
34273449
returnnotification,nil
34283450
}
34293451
}
34303452

3431-
return database.NotificationsInbox{},sql.ErrNoRows
3453+
return database.InboxNotification{},sql.ErrNoRows
34323454
}
34333455

34343456
func (q*FakeQuerier)GetJFrogXrayScanByWorkspaceAndAgentID(_ context.Context,arg database.GetJFrogXrayScanByWorkspaceAndAgentIDParams) (database.JfrogXrayScan,error) {
@@ -8058,15 +8080,15 @@ func (q *FakeQuerier) InsertGroupMember(_ context.Context, arg database.InsertGr
80588080
returnnil
80598081
}
80608082

8061-
func (q*FakeQuerier)InsertInboxNotification(_ context.Context,arg database.InsertInboxNotificationParams) (database.NotificationsInbox,error) {
8083+
func (q*FakeQuerier)InsertInboxNotification(_ context.Context,arg database.InsertInboxNotificationParams) (database.InboxNotification,error) {
80628084
iferr:=validateDatabaseType(arg);err!=nil {
8063-
return database.NotificationsInbox{},err
8085+
return database.InboxNotification{},err
80648086
}
80658087

80668088
q.mutex.Lock()
80678089
deferq.mutex.Unlock()
80688090

8069-
notification:= database.NotificationsInbox{
8091+
notification:= database.InboxNotification{
80708092
ID:arg.ID,
80718093
UserID:arg.UserID,
80728094
TemplateID:arg.TemplateID,
@@ -8078,7 +8100,7 @@ func (q *FakeQuerier) InsertInboxNotification(_ context.Context, arg database.In
80788100
CreatedAt:time.Now(),
80798101
}
80808102

8081-
q.notificationsInbox=append(q.notificationsInbox,notification)
8103+
q.InboxNotification=append(q.InboxNotification,notification)
80828104
returnnotification,nil
80838105
}
80848106

@@ -9575,9 +9597,9 @@ func (q *FakeQuerier) SetInboxNotificationAsRead(_ context.Context, arg database
95759597
q.mutex.Lock()
95769598
deferq.mutex.Unlock()
95779599

9578-
fori:=rangeq.notificationsInbox {
9579-
ifq.notificationsInbox[i].ID==arg.ID {
9580-
q.notificationsInbox[i].ReadAt=arg.ReadAt
9600+
fori:=rangeq.InboxNotification {
9601+
ifq.InboxNotification[i].ID==arg.ID {
9602+
q.InboxNotification[i].ReadAt=arg.ReadAt
95819603
}
95829604
}
95839605

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp