From 8785cdc53c30cc8fbdceae1e37c7ce25ddb84dcf Mon Sep 17 00:00:00 2001 From: Mayura Deshmukh Date: Tue, 7 Jun 2022 17:44:53 +0530 Subject: [PATCH] MOSIP-22357 fixed notf issue from batch job --- .../service/NotificationService.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java index 74a25332803..dbf57686f96 100644 --- a/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java +++ b/pre-registration/pre-registration-application-service/src/main/java/io/mosip/preregistration/application/service/NotificationService.java @@ -219,7 +219,7 @@ public MainResponseDTO sendNotification(String jsonStri log.info("sessionId", "idType", "id", "In notification service of sendNotification if additionalRecipient is" + notificationDto.isAdditionalRecipient()); - resp = getDemographicDetailsWithPreId(bookingType, demoDetail, notificationDto, langCode, file); + resp = getDemographicDetailsWithPreId(bookingType, demoDetail, appEntity, notificationDto, langCode, file); notificationResponse.setMessage(resp); } } @@ -261,7 +261,7 @@ public MainResponseDTO sendNotification(String jsonStri * @throws IOException */ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDTO responseEntity, - NotificationDTO notificationDto, String langCode, MultipartFile file) throws IOException { + MainResponseDTO appEntity, NotificationDTO notificationDto, String langCode, MultipartFile file) throws IOException { try { List> langaueNamePairs = new ArrayList>(); if (BookingTypeCodes.NEW_PREREGISTRATION.toString().equals(bookingType)) { @@ -301,6 +301,12 @@ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDT "In notification service of sendNotification failed to send Email and sms request "); } } else { + //handle notifications for other booking types like LOST_FORGOTTEN_UIN, MISCELLANEOUS_PURPOSE etc + if (notificationDto.getName() == null) { + //in case name is null, set applicationId as name + String applicationId = appEntity.getResponse().getApplicationId(); + notificationDto.setName(applicationId); + } KeyValuePairDto langaueNamePair = null; langaueNamePair = new KeyValuePairDto(); langaueNamePair.setKey(notificationDto.getLanguageCode()); @@ -314,8 +320,24 @@ private String getDemographicDetailsWithPreId(String bookingType, MainResponseDT notificationUtil.notify(NotificationRequestCodes.SMS.getCode(), notificationDto, file); } if (notificationDto.getEmailID() == null && notificationDto.getMobNum() == null ) { - log.info("sessionId", "idType", "id", - "In notification service of sendNotification failed to send Email and sms request "); + //in case both email id and mob num are null, send details to contact info + String createdById = appEntity.getResponse().getContactInfo(); + if (createdById != null) { + if (validationUtil.emailValidator(createdById)) { + notificationDto.setEmailID(createdById); + notificationUtil.notify(NotificationRequestCodes.EMAIL.getCode(), notificationDto, file); + } + else if (validationUtil.phoneValidator(createdById)) { + notificationDto.setMobNum(createdById); + notificationUtil.notify(NotificationRequestCodes.SMS.getCode(), notificationDto, file); + } else { + log.info("sessionId", "idType", "id", + "In notification service of sendNotification failed to send Email and sms request "); + } + } else { + log.info("sessionId", "idType", "id", + "In notification service of sendNotification failed to send Email and sms request "); + } } } return NotificationRequestCodes.MESSAGE.getCode();