diff --git a/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java b/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java index ae1566ff4..a703dd88b 100644 --- a/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java +++ b/dmp-backend/notification-service/notification-web/src/main/java/gr/cite/notification/web/controllers/InAppNotificationController.java @@ -124,7 +124,7 @@ public class InAppNotificationController { @PostMapping("read-all") @Transactional - public Boolean MarkAsReadAllUserInAppNotification() throws InvalidApplicationException, NoSuchFieldException { + public Boolean MarkAsReadAllUserInAppNotification() throws InvalidApplicationException { logger.debug(new MapLogEntry("marking as read all")); UUID userId = this.userScope.getUserId(); diff --git a/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml b/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml index 7ad90ce91..7192cf334 100644 --- a/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml +++ b/dmp-backend/notification-service/notification-web/target/classes/config/notification.yml @@ -335,6 +335,163 @@ notification: '[{recipient}]': null priority-key: null cipher-fields: [ ] + - #dmpModified + key: 4542262A-22F8-4BAA-9DB6-1C8E70AC1DBB + subject-path: classpath:notification_templates/dmpmodified/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/dmpmodified/inapp/body.{language}.html + body-field-options: + mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{reasonName}]': null + '[{name}]': null + '[{installation-url}]': null + '[{id}]': null + '[{recipient}]': null + priority-key: null + cipher-fields: [ ] + - #dmpFinalised + key: 90DB0B46-42DE-BD89-AEBF-6F27EFEB256E + subject-path: classpath:notification_templates/dmpfinalised/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/dmpfinalised/inapp/body.{language}.html + body-field-options: + mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{reasonName}]': null + '[{name}]': null + '[{installation-url}]': null + '[{id}]': null + '[{recipient}]': null + priority-key: null + cipher-fields: [ ] + - #desriptionModified + key: 4FDBFA80-7A71-4A69-B854-67CBB70648F1 + subject-path: classpath:notification_templates/descriptionmodified/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/descriptionmodified/inapp/body.{language}.html + body-field-options: + mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{reasonName}]': null + '[{name}]': null + '[{installation-url}]': null + '[{id}]': null + '[{recipient}]': null + priority-key: null + cipher-fields: [ ] + - #descriptionFinalised + key: 33790bad-94d4-488a-8ee2-7f6295ca18ea + subject-path: classpath:notification_templates/descriptionfinalised/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/descriptionfinalised/inapp/body.{language}.html + body-field-options: + mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{reasonName}]': null + '[{name}]': null + '[{installation-url}]': null + '[{id}]': null + '[{recipient}]': null + priority-key: null + cipher-fields: [ ] + - #mergeAccountConfirmation + key: BFE68845-CB05-4C5A-A03D-29161A7C9660 + subject-path: classpath:notification_templates/mergeacountconfirmation/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/mergeacountconfirmation/inapp/body.{language}.html + body-field-options: + mandatory: [ "{userName}", "{installation-url}", "{confirmationToken}" ] + optional: + - key: "{expiration_time}" + value: --- + formatting: + '[{userName}]': null + '[{installation-url}]': null + '[{confirmationToken}]': null + '[{expiration_time}]': null + priority-key: null + cipher-fields: [ ] + - #removeCredentialConfirmation + key: C9BC3F16-057E-4BBA-8A5F-36BD835E5604 + subject-path: classpath:notification_templates/removecredentialconfirmation/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ "{installation-url}", "{confirmationToken}" ] + optional: [ ] + body-path: classpath:notification_templates/removecredentialconfirmation/inapp/body.{language}.html + body-field-options: + mandatory: [ ] + optional: + - key: "{email}" + value: email + - key: "{expiration_time}" + value: -- + formatting: + '[{email}]': null + '[{expiration_time}]': null + priority-key: null + cipher-fields: [ ] + - #dmpDeposit + key: 55736F7A-83AB-4190-AF43-9D031A6F9612 + subject-path: classpath:notification_templates/dmpdeposit/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/dmpdeposit/inapp/body.{language}.html + body-field-options: + mandatory: [ "{reasonName}", "{name}", "{installation-url}", "{id}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{reasonName}]': null + '[{name}]': null + '[{installation-url}]': null + '[{id}]': null + '[{recipient}]': null + priority-key: null + cipher-fields: [ ] + - #descriptionTemplateInvitation + key: 223BB607-EFA1-4CE7-99EC-4BEABFEF9A8B + subject-path: classpath:notification_templates/descriptiontemplateinvitation/inapp/subject.{language}.txt + subject-field-options: + mandatory: [ ] + optional: [ ] + body-path: classpath:notification_templates/descriptiontemplateinvitation/inapp/body.{language}.html + body-field-options: + mandatory: [ "{templateName}", "{installation-url}", "{templateID}" ] + optional: + - key: "{recipient}" + value: + formatting: + '[{templateName}]': null + '[{installation-url}]': null + '[{templateID}]': null + '[{recipient}]': null + priority-key: null + cipher-fields: [ ] template-cache: prefix: ${CACHE_DISAMBIGUATION:} key-pattern: "{prefix}:Notification_Message_InApp_Template:{key}:v0" diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationService.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationService.java index 45a87249b..fb0129b8a 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationService.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationService.java @@ -9,5 +9,5 @@ public interface InAppNotificationService { void markAsRead(List ids); void markAsRead(UUID id); void deleteAndSave(UUID id) throws InvalidApplicationException; - void markAsReadAllUserNotification(UUID userId) throws NoSuchFieldException; + void markAsReadAllUserNotification(UUID userId); } diff --git a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java index dab1ac65f..9640fc0ef 100644 --- a/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java +++ b/dmp-backend/notification-service/notification/src/main/java/gr/cite/notification/service/inappnotification/InAppNotificationServiceImpl.java @@ -68,23 +68,18 @@ public class InAppNotificationServiceImpl implements InAppNotificationService{ } } - public void markAsReadAllUserNotification(UUID userId) throws NoSuchFieldException { - + public void markAsReadAllUserNotification(UUID userId) { String entity = InAppNotificationEntity.class.getSimpleName(); - String trackingStateProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._trackingState).getAnnotation(Column.class).name().replace("\"", ""); - String updateProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._updatedAt).getAnnotation(Column.class).name().replace("\"", ""); - String readTimeProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._readTime).getAnnotation(Column.class).name().replace("\"", ""); - String userProperty = InAppNotificationEntity.class.getDeclaredField(InAppNotificationEntity.Field._userId).getAnnotation(Column.class).name().replace("\"", ""); - String sqlQuery = "UPDATE " + entity + " SET "+ trackingStateProperty +" = :trackingState, "+ updateProperty + "= :updatedAt, " + readTimeProperty + " = :readTime " + - "WHERE " + trackingStateProperty + " = :trackingStateCondition";//TODO AND \"'user\" = :userId"; + String sqlQuery = "UPDATE " + entity + " as e SET "+ InAppNotificationEntity.Field._trackingState +" = :trackingState, "+ InAppNotificationEntity.Field._updatedAt + "= :updatedAt, " + InAppNotificationEntity.Field._readTime + " = :readTime " + + "WHERE e." + InAppNotificationEntity.Field._trackingState + " = :trackingStateCondition AND e."+ InAppNotificationEntity.Field._userId + " = :userId"; Query query = this.entityManager.createQuery(sqlQuery) - .setParameter("trackingState", NotificationInAppTracking.DELIVERED.getValue()) + .setParameter("trackingState", NotificationInAppTracking.DELIVERED) .setParameter("updatedAt", Instant.now()) .setParameter("readTime", Instant.now()) - //.setParameter("userId", userId) - .setParameter("trackingStateCondition", NotificationInAppTracking.STORED.getValue()); + .setParameter("userId", userId) + .setParameter("trackingStateCondition", NotificationInAppTracking.STORED); int updateCount = query.executeUpdate(); }