@@ -67,7 +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
+ InboxNotification :make ([]database.InboxNotification ,0 ),
71
71
parameterSchemas :make ([]database.ParameterSchema ,0 ),
72
72
provisionerDaemons :make ([]database.ProvisionerDaemon ,0 ),
73
73
provisionerKeys :make ([]database.ProvisionerKey ,0 ),
@@ -207,7 +207,7 @@ type data struct {
207
207
notificationMessages []database.NotificationMessage
208
208
notificationPreferences []database.NotificationPreference
209
209
notificationReportGeneratorLogs []database.NotificationReportGeneratorLog
210
- notificationsInbox []database.NotificationsInbox
210
+ InboxNotification []database.InboxNotification
211
211
oauth2ProviderApps []database.OAuth2ProviderApp
212
212
oauth2ProviderAppSecrets []database.OAuth2ProviderAppSecret
213
213
oauth2ProviderAppCodes []database.OAuth2ProviderAppCode
@@ -2365,12 +2365,12 @@ func (q *FakeQuerier) FavoriteWorkspace(_ context.Context, arg uuid.UUID) error
2365
2365
return nil
2366
2366
}
2367
2367
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 ) {
2369
2369
q .mutex .RLock ()
2370
2370
defer q .mutex .RUnlock ()
2371
2371
2372
- notifications := make ([]database.NotificationsInbox ,0 )
2373
- for _ ,notification := range q .notificationsInbox {
2372
+ notifications := make ([]database.InboxNotification ,0 )
2373
+ for _ ,notification := range q .InboxNotification {
2374
2374
if notification .UserID == userID {
2375
2375
notifications = append (notifications ,notification )
2376
2376
}
@@ -2379,13 +2379,24 @@ func (q *FakeQuerier) FetchInboxNotificationsByUserID(_ context.Context, userID
2379
2379
return notifications ,nil
2380
2380
}
2381
2381
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 ) {
2383
2383
q .mutex .RLock ()
2384
2384
defer q .mutex .RUnlock ()
2385
2385
2386
- notifications := make ([]database.NotificationsInbox ,0 )
2387
- for _ ,notification := range q .notificationsInbox {
2388
- if notification .UserID == arg .UserID && notification .TemplateID == arg .TemplateID {
2386
+ notifications := make ([]database.InboxNotification ,0 )
2387
+ for _ ,notification := range q .InboxNotification {
2388
+ if notification .UserID == arg .UserID {
2389
+ for _ ,template := range arg .Templates {
2390
+ templateFound := false
2391
+ if notification .TemplateID == template {
2392
+ templateFound = true
2393
+ }
2394
+
2395
+ if ! templateFound {
2396
+ continue
2397
+ }
2398
+ }
2399
+
2389
2400
for _ ,target := range arg .Targets {
2390
2401
isFound := false
2391
2402
for _ ,insertedTarget := range notification .Targets {
@@ -2449,12 +2460,12 @@ func (q *FakeQuerier) FetchNewMessageMetadata(_ context.Context, arg database.Fe
2449
2460
},nil
2450
2461
}
2451
2462
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 ) {
2453
2464
q .mutex .RLock ()
2454
2465
defer q .mutex .RUnlock ()
2455
2466
2456
- notifications := make ([]database.NotificationsInbox ,0 )
2457
- for _ ,notification := range q .notificationsInbox {
2467
+ notifications := make ([]database.InboxNotification ,0 )
2468
+ for _ ,notification := range q .InboxNotification {
2458
2469
if notification .UserID == userID && ! notification .ReadAt .Valid {
2459
2470
notifications = append (notifications ,notification )
2460
2471
}
@@ -2463,13 +2474,24 @@ func (q *FakeQuerier) FetchUnreadInboxNotificationsByUserID(_ context.Context, u
2463
2474
return notifications ,nil
2464
2475
}
2465
2476
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 ) {
2467
2478
q .mutex .RLock ()
2468
2479
defer q .mutex .RUnlock ()
2469
2480
2470
- notifications := make ([]database.NotificationsInbox ,0 )
2471
- for _ ,notification := range q .notificationsInbox {
2472
- if notification .UserID == arg .UserID && notification .TemplateID == arg .TemplateID && ! notification .ReadAt .Valid {
2481
+ notifications := make ([]database.InboxNotification ,0 )
2482
+ for _ ,notification := range q .InboxNotification {
2483
+ if notification .UserID == arg .UserID && ! notification .ReadAt .Valid {
2484
+ for _ ,template := range arg .Templates {
2485
+ templateFound := false
2486
+ if notification .TemplateID == template {
2487
+ templateFound = true
2488
+ }
2489
+
2490
+ if ! templateFound {
2491
+ continue
2492
+ }
2493
+ }
2494
+
2473
2495
for _ ,target := range arg .Targets {
2474
2496
isFound := false
2475
2497
for _ ,insertedTarget := range notification .Targets {
@@ -3418,17 +3440,17 @@ func (q *FakeQuerier) GetHungProvisionerJobs(_ context.Context, hungSince time.T
3418
3440
return hungJobs ,nil
3419
3441
}
3420
3442
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 ) {
3422
3444
q .mutex .RLock ()
3423
3445
defer q .mutex .RUnlock ()
3424
3446
3425
- for _ ,notification := range q .notificationsInbox {
3447
+ for _ ,notification := range q .InboxNotification {
3426
3448
if notification .ID == id {
3427
3449
return notification ,nil
3428
3450
}
3429
3451
}
3430
3452
3431
- return database.NotificationsInbox {},sql .ErrNoRows
3453
+ return database.InboxNotification {},sql .ErrNoRows
3432
3454
}
3433
3455
3434
3456
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
8058
8080
return nil
8059
8081
}
8060
8082
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 ) {
8062
8084
if err := validateDatabaseType (arg );err != nil {
8063
- return database.NotificationsInbox {},err
8085
+ return database.InboxNotification {},err
8064
8086
}
8065
8087
8066
8088
q .mutex .Lock ()
8067
8089
defer q .mutex .Unlock ()
8068
8090
8069
- notification := database.NotificationsInbox {
8091
+ notification := database.InboxNotification {
8070
8092
ID :arg .ID ,
8071
8093
UserID :arg .UserID ,
8072
8094
TemplateID :arg .TemplateID ,
@@ -8078,7 +8100,7 @@ func (q *FakeQuerier) InsertInboxNotification(_ context.Context, arg database.In
8078
8100
CreatedAt :time .Now (),
8079
8101
}
8080
8102
8081
- q .notificationsInbox = append (q .notificationsInbox ,notification )
8103
+ q .InboxNotification = append (q .InboxNotification ,notification )
8082
8104
return notification ,nil
8083
8105
}
8084
8106
@@ -9575,9 +9597,9 @@ func (q *FakeQuerier) SetInboxNotificationAsRead(_ context.Context, arg database
9575
9597
q .mutex .Lock ()
9576
9598
defer q .mutex .Unlock ()
9577
9599
9578
- for i := range q .notificationsInbox {
9579
- if q .notificationsInbox [i ].ID == arg .ID {
9580
- q .notificationsInbox [i ].ReadAt = arg .ReadAt
9600
+ for i := range q .InboxNotification {
9601
+ if q .InboxNotification [i ].ID == arg .ID {
9602
+ q .InboxNotification [i ].ReadAt = arg .ReadAt
9581
9603
}
9582
9604
}
9583
9605