@@ -67,6 +67,7 @@ func New() database.Store {
67
67
gitSSHKey :make ([]database.GitSSHKey ,0 ),
68
68
notificationMessages :make ([]database.NotificationMessage ,0 ),
69
69
notificationPreferences :make ([]database.NotificationPreference ,0 ),
70
+ notificationsInbox :make ([]database.NotificationsInbox ,0 ),
70
71
parameterSchemas :make ([]database.ParameterSchema ,0 ),
71
72
provisionerDaemons :make ([]database.ProvisionerDaemon ,0 ),
72
73
provisionerKeys :make ([]database.ProvisionerKey ,0 ),
@@ -206,6 +207,7 @@ type data struct {
206
207
notificationMessages []database.NotificationMessage
207
208
notificationPreferences []database.NotificationPreference
208
209
notificationReportGeneratorLogs []database.NotificationReportGeneratorLog
210
+ notificationsInbox []database.NotificationsInbox
209
211
oauth2ProviderApps []database.OAuth2ProviderApp
210
212
oauth2ProviderAppSecrets []database.OAuth2ProviderAppSecret
211
213
oauth2ProviderAppCodes []database.OAuth2ProviderAppCode
@@ -2363,17 +2365,32 @@ func (q *FakeQuerier) FavoriteWorkspace(_ context.Context, arg uuid.UUID) error
2363
2365
return nil
2364
2366
}
2365
2367
2366
- func (q * FakeQuerier )FetchInboxNotificationsByUserID (ctx context.Context ,userID uuid.UUID ) ([]database.NotificationsInbox ,error ) {
2367
- panic ("not implemented" )
2368
+ func (q * FakeQuerier )FetchInboxNotificationsByUserID (_ context.Context ,userID uuid.UUID ) ([]database.NotificationsInbox ,error ) {
2369
+ q .mutex .RLock ()
2370
+ defer q .mutex .RUnlock ()
2371
+
2372
+ notifications := make ([]database.NotificationsInbox ,0 )
2373
+ for _ ,notification := range q .notificationsInbox {
2374
+ if notification .UserID == userID {
2375
+ notifications = append (notifications ,notification )
2376
+ }
2377
+ }
2378
+
2379
+ return notifications ,nil
2368
2380
}
2369
2381
2370
- func (q * FakeQuerier )FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID (ctx context.Context ,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams ) ([]database.NotificationsInbox ,error ) {
2371
- err := validateDatabaseType (arg )
2372
- if err != nil {
2373
- return nil ,err
2382
+ func (q * FakeQuerier )FetchInboxNotificationsByUserIDAndTemplateIDAndTargetID (_ context.Context ,arg database.FetchInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams ) ([]database.NotificationsInbox ,error ) {
2383
+ q .mutex .RLock ()
2384
+ defer q .mutex .RUnlock ()
2385
+
2386
+ notifications := make ([]database.NotificationsInbox ,0 )
2387
+ for _ ,notification := range q .notificationsInbox {
2388
+ if notification .UserID == arg .UserID && notification .TemplateID == arg .TemplateID && notification .TargetID == arg .TargetID {
2389
+ notifications = append (notifications ,notification )
2390
+ }
2374
2391
}
2375
2392
2376
- panic ( "not implemented" )
2393
+ return notifications , nil
2377
2394
}
2378
2395
2379
2396
func (q * FakeQuerier )FetchMemoryResourceMonitorsByAgentID (_ context.Context ,agentID uuid.UUID ) (database.WorkspaceAgentMemoryResourceMonitor ,error ) {
@@ -2418,17 +2435,32 @@ func (q *FakeQuerier) FetchNewMessageMetadata(_ context.Context, arg database.Fe
2418
2435
},nil
2419
2436
}
2420
2437
2421
- func (q * FakeQuerier )FetchUnreadInboxNotificationsByUserID (ctx context.Context ,userID uuid.UUID ) ([]database.NotificationsInbox ,error ) {
2422
- panic ("not implemented" )
2438
+ func (q * FakeQuerier )FetchUnreadInboxNotificationsByUserID (_ context.Context ,userID uuid.UUID ) ([]database.NotificationsInbox ,error ) {
2439
+ q .mutex .RLock ()
2440
+ defer q .mutex .RUnlock ()
2441
+
2442
+ notifications := make ([]database.NotificationsInbox ,0 )
2443
+ for _ ,notification := range q .notificationsInbox {
2444
+ if notification .UserID == userID && ! notification .ReadAt .Valid {
2445
+ notifications = append (notifications ,notification )
2446
+ }
2447
+ }
2448
+
2449
+ return notifications ,nil
2423
2450
}
2424
2451
2425
- func (q * FakeQuerier )FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID (ctx context.Context ,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams ) ([]database.NotificationsInbox ,error ) {
2426
- err := validateDatabaseType (arg )
2427
- if err != nil {
2428
- return nil ,err
2452
+ func (q * FakeQuerier )FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetID (_ context.Context ,arg database.FetchUnreadInboxNotificationsByUserIDAndTemplateIDAndTargetIDParams ) ([]database.NotificationsInbox ,error ) {
2453
+ q .mutex .RLock ()
2454
+ defer q .mutex .RUnlock ()
2455
+
2456
+ notifications := make ([]database.NotificationsInbox ,0 )
2457
+ for _ ,notification := range q .notificationsInbox {
2458
+ if notification .UserID == arg .UserID && notification .TemplateID == arg .TemplateID && notification .TargetID == arg .TargetID && ! notification .ReadAt .Valid {
2459
+ notifications = append (notifications ,notification )
2460
+ }
2429
2461
}
2430
2462
2431
- panic ( "not implemented" )
2463
+ return notifications , nil
2432
2464
}
2433
2465
2434
2466
func (q * FakeQuerier )FetchVolumesResourceMonitorsByAgentID (_ context.Context ,agentID uuid.UUID ) ([]database.WorkspaceAgentVolumeResourceMonitor ,error ) {
@@ -3358,8 +3390,17 @@ func (q *FakeQuerier) GetHungProvisionerJobs(_ context.Context, hungSince time.T
3358
3390
return hungJobs ,nil
3359
3391
}
3360
3392
3361
- func (q * FakeQuerier )GetInboxNotificationByID (ctx context.Context ,id uuid.UUID ) (database.NotificationsInbox ,error ) {
3362
- panic ("not implemented" )
3393
+ func (q * FakeQuerier )GetInboxNotificationByID (_ context.Context ,id uuid.UUID ) (database.NotificationsInbox ,error ) {
3394
+ q .mutex .RLock ()
3395
+ defer q .mutex .RUnlock ()
3396
+
3397
+ for _ ,notification := range q .notificationsInbox {
3398
+ if notification .ID == id {
3399
+ return notification ,nil
3400
+ }
3401
+ }
3402
+
3403
+ return database.NotificationsInbox {},sql .ErrNoRows
3363
3404
}
3364
3405
3365
3406
func (q * FakeQuerier )GetJFrogXrayScanByWorkspaceAndAgentID (_ context.Context ,arg database.GetJFrogXrayScanByWorkspaceAndAgentIDParams ) (database.JfrogXrayScan ,error ) {
@@ -7989,13 +8030,28 @@ func (q *FakeQuerier) InsertGroupMember(_ context.Context, arg database.InsertGr
7989
8030
return nil
7990
8031
}
7991
8032
7992
- func (q * FakeQuerier )InsertInboxNotification (ctx context.Context ,arg database.InsertInboxNotificationParams ) (database.NotificationsInbox ,error ) {
7993
- err := validateDatabaseType (arg )
7994
- if err != nil {
8033
+ func (q * FakeQuerier )InsertInboxNotification (_ context.Context ,arg database.InsertInboxNotificationParams ) (database.NotificationsInbox ,error ) {
8034
+ if err := validateDatabaseType (arg );err != nil {
7995
8035
return database.NotificationsInbox {},err
7996
8036
}
7997
8037
7998
- panic ("not implemented" )
8038
+ q .mutex .Lock ()
8039
+ defer q .mutex .Unlock ()
8040
+
8041
+ notification := database.NotificationsInbox {
8042
+ ID :arg .ID ,
8043
+ UserID :arg .UserID ,
8044
+ TemplateID :arg .TemplateID ,
8045
+ TargetID :arg .TargetID ,
8046
+ Title :arg .Title ,
8047
+ Content :arg .Content ,
8048
+ Icon :arg .Icon ,
8049
+ Actions :arg .Actions ,
8050
+ CreatedAt :time .Now (),
8051
+ }
8052
+
8053
+ q .notificationsInbox = append (q .notificationsInbox ,notification )
8054
+ return notification ,nil
7999
8055
}
8000
8056
8001
8057
func (q * FakeQuerier )InsertLicense (
@@ -9482,13 +9538,22 @@ func (q *FakeQuerier) RevokeDBCryptKey(_ context.Context, activeKeyDigest string
9482
9538
return sql .ErrNoRows
9483
9539
}
9484
9540
9485
- func (q * FakeQuerier )SetInboxNotificationAsRead (ctx context.Context ,arg database.SetInboxNotificationAsReadParams )error {
9541
+ func (q * FakeQuerier )SetInboxNotificationAsRead (_ context.Context ,arg database.SetInboxNotificationAsReadParams )error {
9486
9542
err := validateDatabaseType (arg )
9487
9543
if err != nil {
9488
9544
return err
9489
9545
}
9490
9546
9491
- panic ("not implemented" )
9547
+ q .mutex .Lock ()
9548
+ defer q .mutex .Unlock ()
9549
+
9550
+ for i := range q .notificationsInbox {
9551
+ if q .notificationsInbox [i ].ID == arg .ID {
9552
+ q .notificationsInbox [i ].ReadAt = arg .ReadAt
9553
+ }
9554
+ }
9555
+
9556
+ return nil
9492
9557
}
9493
9558
9494
9559
func (* FakeQuerier )TryAcquireLock (_ context.Context ,_ int64 ) (bool ,error ) {