Skip to content

Commit

Permalink
MOSIP-37024 Fixed notification issue
Browse files Browse the repository at this point in the history
Signed-off-by: kameshsr <kameshsr1338@gmail.com>
  • Loading branch information
kameshsr committed Nov 12, 2024
1 parent 1b45e6f commit 11f3629
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class SMSServiceProviderImpl implements SMSServiceProvider {
@Value("${mosip.kernel.sms.unicode:1}")
String unicode;

@Value("${mosip.id.validation.identity.phone}")
private String phoneRegex;

@Override
public SMSResponseDto sendSms(String contactNumber, String message) {
SMSResponseDto smsResponseDTO = new SMSResponseDto();
Expand All @@ -86,16 +89,14 @@ public SMSResponseDto sendSms(String contactNumber, String message) {
}

private void validateInput(String contactNumber) {
if (!StringUtils.isNumeric(contactNumber) || (!inRange(contactNumber.length(), numberMinLength,
numberMaxLength))) {
if (!phoneValidator(contactNumber)) {
throw new InvalidNumberException(SmsExceptionConstant.SMS_INVALID_CONTACT_NUMBER.getErrorCode(),
SmsExceptionConstant.SMS_INVALID_CONTACT_NUMBER.getErrorMessage() + numberMinLength + "-"
+ numberMaxLength + SmsPropertyConstant.SUFFIX_MESSAGE.getProperty());
SmsExceptionConstant.SMS_INVALID_CONTACT_NUMBER.getErrorMessage());
}
}

private boolean inRange(int value, int min, int max) {
return (value >= min) && (value <= max);
public boolean phoneValidator(String phone) {
return phone.matches(phoneRegex);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer
@Value("${mosip.kernel.sms.route}")
String route;

@Value("${mosip.id.validation.identity.phone}")
private String phoneRegex;

@Value("${phone}")
private String phone;

@Test
public void sendSmsTest() {

Expand Down Expand Up @@ -108,7 +114,7 @@ public void contactNumberMaximumThresholdTest() {

@Test
public void validGateWayTest() {
service.sendSms("1234567890", "hello your otp is 45373");
service.sendSms(phone, "hello your otp is 45373");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ auth.server.validate.url=https://dev.mosip.io/authmanager/v1.0/authorize/validat
logging.level.org.springframework=OFF
logging.level.root=OFF
spring.main.banner-mode=off
mosip.id.validation.identity.phone=^[+]*([0-9]{1})([0-9]{9})$
phone=1234567890

0 comments on commit 11f3629

Please sign in to comment.