1
1
package com .redhat .cloud .notifications .routers ;
2
2
3
+ import com .redhat .cloud .notifications .config .BackendConfig ;
3
4
import com .redhat .cloud .notifications .db .Query ;
4
5
import com .redhat .cloud .notifications .db .repositories .DrawerNotificationRepository ;
5
6
import com .redhat .cloud .notifications .models .DrawerEntryPayload ;
@@ -39,6 +40,9 @@ public class DrawerResource {
39
40
@ Inject
40
41
DrawerNotificationRepository drawerRepository ;
41
42
43
+ @ Inject
44
+ BackendConfig backendConfig ;
45
+
42
46
@ Path (API_NOTIFICATIONS_V_1_0 + "/notifications/drawer" )
43
47
public static class V1 extends DrawerResource {
44
48
@@ -58,10 +62,13 @@ public Page<DrawerEntryPayload> getDrawerEntries(@Context SecurityContext securi
58
62
String orgId = getOrgId (securityContext );
59
63
String username = getUsername (securityContext );
60
64
LocalDateTime start = LocalDateTime .now ();
61
- Long count = drawerRepository .count (orgId , username , bundleIds , appIds , eventTypeIds , startDate , endDate , readStatus );
62
65
List <DrawerEntryPayload > drawerEntries = new ArrayList <>();
63
- if (count > 0 ) {
64
- drawerEntries = drawerRepository .getNotifications (orgId , username , bundleIds , appIds , eventTypeIds , startDate , endDate , readStatus , query );
66
+ Long count = 0L ;
67
+ if (backendConfig .isDrawerEnabled ()) {
68
+ count = drawerRepository .count (orgId , username , bundleIds , appIds , eventTypeIds , startDate , endDate , readStatus );
69
+ if (count > 0 ) {
70
+ drawerEntries = drawerRepository .getNotifications (orgId , username , bundleIds , appIds , eventTypeIds , startDate , endDate , readStatus , query );
71
+ }
65
72
}
66
73
LocalDateTime now = LocalDateTime .now ();
67
74
Log .infof ("Drawer request duration %s for orgId: %s, userId: %s" ,
0 commit comments