55import { factories } from '@strapi/strapi' ;
66
77const MODULE_ID = 'api::notification.notification'
8- const GLOBAL_MODULE_ID = 'api::notifications-consumer.notifications-consumer'
8+ const NOTIFICATIONS_CONSUMER_MODULE_ID = 'api::notifications-consumer.notifications-consumer'
99const SINGLETON_ID = 1
10+ const NOTIFICATIONS_LIMIT = 50
1011
1112const NOTIFICATIONS_POPULATE = {
1213 notification_template : {
@@ -39,7 +40,7 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
3940 MODULE_ID ,
4041 {
4142 start : 0 ,
42- limit : 50 ,
43+ limit : NOTIFICATIONS_LIMIT ,
4344 filters : {
4445 account : { $null : true } ,
4546 notification_template : notificationsTemplateFilter ( push )
@@ -55,7 +56,7 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
5556 MODULE_ID ,
5657 {
5758 start : 0 ,
58- limit : 50 ,
59+ limit : NOTIFICATIONS_LIMIT ,
5960 filters : {
6061 $or : [
6162 { account, notification_template : templateFilter } ,
@@ -80,11 +81,11 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
8081 } ,
8182 async getPushNotifications ( ) {
8283 const push = true
83- const global = await strapi . entityService . findOne ( GLOBAL_MODULE_ID , SINGLETON_ID , {
84+ const notificationsConsumer = await strapi . entityService . findOne ( NOTIFICATIONS_CONSUMER_MODULE_ID , SINGLETON_ID , {
8485 populate : [ 'id' , 'lastConsumedNotificationDate' ]
8586 } )
8687
87- const lastConsumedNotificationDate = global ?. lastConsumedNotificationDate
88+ const lastConsumedNotificationDate = notificationsConsumer ?. lastConsumedNotificationDate
8889
8990 return strapi . entityService . findMany (
9091 MODULE_ID ,
@@ -102,7 +103,7 @@ export default factories.createCoreService(MODULE_ID, ({ strapi }) => {
102103 } ,
103104 updateLastConsumedNotificationDate ( ) {
104105 return strapi . entityService . update (
105- GLOBAL_MODULE_ID ,
106+ NOTIFICATIONS_CONSUMER_MODULE_ID ,
106107 SINGLETON_ID ,
107108 {
108109 data : { lastConsumedNotificationDate : new Date ( ) }
0 commit comments