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

Rejection report disabled for state all #117

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 @@ -9,5 +9,5 @@ public interface SmsService {

String buildCertificateSMS(CourseCompletionDTO courseCompletionDTO, String message_content);

String buildOTPSMS(MACourseFirstCompletion maCourseFirstCompletion, String message_content);
String buildOTPSMS(MACourseFirstCompletion maCourseFirstCompletion, String message_content, long languageId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public String generateOTPForAshaCertificate(Long mobileNo) throws Exception {
String messageContent = buildOTPMessage(languageId, otp);

MACourseCompletion maCourseCompletion = maCourseCompletionDao.getAshaByFLWId(maCourseFirstCompletion.getFlwId());
return sendOTPMessage(maCourseCompletion, maCourseFirstCompletion, messageContent);
return sendOTPMessage(maCourseCompletion, maCourseFirstCompletion, messageContent, languageId);
}

private int generateRandomSixDigitOTP() {
Expand All @@ -450,8 +450,8 @@ private String buildOTPMessage(long languageId, int otp) {
return messageTemplate.replace("<OTP>", String.valueOf(otp));
}

private String sendOTPMessage(MACourseCompletion maCourseCompletion, MACourseFirstCompletion maCourseFirstCompletion, String messageContent) {
String template = smsService.buildOTPSMS(maCourseFirstCompletion, messageContent);
private String sendOTPMessage(MACourseCompletion maCourseCompletion, MACourseFirstCompletion maCourseFirstCompletion, String messageContent, long languageId) {
String template = smsService.buildOTPSMS(maCourseFirstCompletion, messageContent, languageId);
logger.info("SMS Template: {}", template);
return smsService.sendSms(maCourseCompletion, template);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Service;

import java.io.File;
import java.io.IOException;
import java.io.*;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -149,14 +149,16 @@ public String buildCertificateSMS(CourseCompletionDTO courseCompletionDTO, Strin

// Replace placeholders in the template
try {
String messageType = retrieveAshaCourseCompletionMessageType(courseCompletionDTO.getLanguageId());
template = template
.replace("<phoneNumber>", String.valueOf(phoneNo))
.replace("<senderId>", senderId)
.replace("<messageContent>", messageContent)
.replace("<notificationUrl>", callbackEndpoint)
.replace("<smsTemplateId>", sms_template_id)
.replace("<smsEntityId>", sms_entity_id)
.replace("<smsTelemarketerId>", sms_telemarketer_id);
.replace("<smsTelemarketerId>", sms_telemarketer_id)
.replace("<messageType>", messageType);
} catch (Exception e) {
LOGGER.error("Error replacing placeholders in SMS template", e);
return null;
Expand All @@ -165,7 +167,7 @@ public String buildCertificateSMS(CourseCompletionDTO courseCompletionDTO, Strin
return template;
}

public String buildOTPSMS(MACourseFirstCompletion maCourseFirstCompletion, String messageContent) {
public String buildOTPSMS(MACourseFirstCompletion maCourseFirstCompletion, String messageContent, long languageId) {
long phoneNumber;
String template = null;

Expand Down Expand Up @@ -196,13 +198,15 @@ public String buildOTPSMS(MACourseFirstCompletion maCourseFirstCompletion, Strin
// Populate SMS template
try {
String callbackEndpoint = retrieveAshaSMSCallBackEndPoint("OTP");
String messageType = retrieveAshaCourseCompletionMessageType(languageId);
template = template.replace("<phoneNumber>", String.valueOf(phoneNumber))
.replace("<senderId>", senderId)
.replace("<messageContent>", messageContent)
.replace("<notificationUrl>", callbackEndpoint)
.replace("<smsTemplateId>", sms_template_id)
.replace("<smsEntityId>", sms_entity_id)
.replace("<smsTelemarketerId>", sms_telemarketer_id);
.replace("<smsTelemarketerId>", sms_telemarketer_id)
.replace("<messageType>", messageType);
} catch (Exception e) {
LOGGER.error("Error populating SMS template.", e);
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,14 @@ public static String retrieveAshaCourseCompletionOTPMessage(long languageId) {
return message;
}

public static String retrieveAshaCourseCompletionMessageType(long languageId) {
String message = getProperty("sms.asha.default.message.type." + languageId);
if (message == null) {
message = getProperty("sms.asha.default.message.type");
}
return message;
}

public static String retrieveAshaCertificateDownloadPageUrl() {
return getProperty("sms.asha.certificate.download.url");
}
Expand Down
3 changes: 3 additions & 0 deletions NMSReportingSuite/src/main/resources/sms.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ sms.asha.default.message.10=Avinandan didi, aapana Mobile Akademy korse sampurna
sms.asha.default.message.12=Abhinandan Baideu, apuni Mobile Academy r coursetu sampurna korile. Etia certificate paboloi ei SMS to aponalokar subcentreor meetingot dekhaok. No. \nMoHFW-KMA
sms.asha.default.message.5=Obhinandan Didi! Apni safolyer songe mobile academir training course ti sompurno korechen. Ekhon certificate pawar jonno apnake ei SMS ti sub centre meeting e dyakhate hobe. ( SMS system Dara toiri kora reference sonkhya) \nMoHFW-KMA

sms.asha.default.message.type=0
sms.asha.default.message.type.14=4

## OTP lifespan in seconds to download the certificate
otplifespan=2592000

Expand Down
6 changes: 5 additions & 1 deletion NMSReportingSuite/src/main/resources/smsTemplate.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
"message": "<messageContent>"
},
"clientCorrelator": "<correlationId>",
"messageType": "<messageType>",
"receiptRequest": {
"notifyURL": "<notificationUrl>",
"callbackData": ""
},
"senderName": "",
"category": ""
"category": "",
"templateId": "<smsTemplateId>",
"entityId": "<smsEntityId>",
"telemarketerId": "<smsTelemarketerId>"
}
}
2 changes: 1 addition & 1 deletion app/scripts/controllers/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@

if(!$scope.isCircleReport() ){

if(!$scope.isAggregateReport())
if(!$scope.isAggregateReport() || ( $scope.report && $scope.report.name.toLowerCase().indexOf(("rejected").toLowerCase()) > -1 ) )
{
if($scope.state != null){
reportRequest.stateId = $scope.state.stateId;
Expand Down