+17
-1
@@ -228,7 +228,7 @@ public class MessageHubClientServiceImpl implements MessageHubClientService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<String, Object> templateParams = new HashMap<>();
|
Map<String, Object> templateParams = new HashMap<>();
|
||||||
templateParams.put("name", brandProperties.getMessageTemplateName());
|
templateParams.put("name", resolveSmsTemplateName());
|
||||||
templateParams.put("code", code);
|
templateParams.put("code", code);
|
||||||
templateParams.put("min", "5");
|
templateParams.put("min", "5");
|
||||||
templateParams.put("minutes", "5");
|
templateParams.put("minutes", "5");
|
||||||
@@ -237,4 +237,20 @@ public class MessageHubClientServiceImpl implements MessageHubClientService {
|
|||||||
messageBody.put("templateParams", templateParams);
|
messageBody.put("templateParams", templateParams);
|
||||||
return messageBody;
|
return messageBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String resolveSmsTemplateName() {
|
||||||
|
String configuredName = brandProperties.getMessageTemplateName();
|
||||||
|
if (!StringUtils.hasText(configuredName)) {
|
||||||
|
return "Salon";
|
||||||
|
}
|
||||||
|
StringBuilder normalizedName = new StringBuilder();
|
||||||
|
configuredName.codePoints()
|
||||||
|
.filter(codePoint -> (codePoint >= 'A' && codePoint <= 'Z')
|
||||||
|
|| (codePoint >= 'a' && codePoint <= 'z')
|
||||||
|
|| (codePoint >= '0' && codePoint <= '9')
|
||||||
|
|| Character.UnicodeScript.of(codePoint) == Character.UnicodeScript.HAN)
|
||||||
|
.limit(10)
|
||||||
|
.forEach(normalizedName::appendCodePoint);
|
||||||
|
return normalizedName.length() == 0 ? "Salon" : normalizedName.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user