Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-22357 fixed notf issue from batch job #557

Merged
merged 1 commit into from
Jun 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public MainResponseDTO<NotificationResponseDTO> 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);
}
}
Expand Down Expand Up @@ -261,7 +261,7 @@ public MainResponseDTO<NotificationResponseDTO> sendNotification(String jsonStri
* @throws IOException
*/
private String getDemographicDetailsWithPreId(String bookingType, MainResponseDTO<DemographicResponseDTO> responseEntity,
NotificationDTO notificationDto, String langCode, MultipartFile file) throws IOException {
MainResponseDTO<ApplicationEntity> appEntity, NotificationDTO notificationDto, String langCode, MultipartFile file) throws IOException {
try {
List<KeyValuePairDto<String,String>> langaueNamePairs = new ArrayList<KeyValuePairDto<String,String>>();
if (BookingTypeCodes.NEW_PREREGISTRATION.toString().equals(bookingType)) {
Expand Down Expand Up @@ -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());
Expand All @@ -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();
Expand Down