Continue structural port from Spring Boot to Undertow
- Notification template generator - Add tests for email notification handler
This commit is contained in:
@@ -28,10 +28,10 @@ public class EmailTemplateConfig extends GenericTemplateConfig {
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
|
||||
|
||||
public EmailTemplateConfig() {
|
||||
setInvite("classpath:threepids/email/invite-template.eml");
|
||||
getGeneric().put("matrixId", "classpath:threepids/email/mxid-template.eml");
|
||||
getSession().getValidation().setLocal("classpath:threepids/email/validate-local-template.eml");
|
||||
getSession().getValidation().setRemote("classpath:threepids/email/validate-remote-template.eml");
|
||||
setInvite("classpath:/threepids/email/invite-template.eml");
|
||||
getGeneric().put("matrixId", "classpath:/threepids/email/mxid-template.eml");
|
||||
getSession().getValidation().setLocal("classpath:/threepids/email/validate-local-template.eml");
|
||||
getSession().getValidation().setRemote("classpath:/threepids/email/validate-remote-template.eml");
|
||||
}
|
||||
|
||||
public EmailTemplateConfig build() {
|
||||
|
||||
@@ -28,10 +28,10 @@ public class PhoneSmsTemplateConfig extends GenericTemplateConfig {
|
||||
private transient final Logger log = LoggerFactory.getLogger(EmailTemplateConfig.class);
|
||||
|
||||
public PhoneSmsTemplateConfig() {
|
||||
setInvite("classpath:threepids/sms/invite-template.txt");
|
||||
getGeneric().put("matrixId", "classpath:threepids/email/mxid-template.eml");
|
||||
getSession().getValidation().setLocal("classpath:threepids/sms/validate-local-template.txt");
|
||||
getSession().getValidation().setRemote("classpath:threepids/sms/validate-remote-template.txt");
|
||||
setInvite("classpath:/threepids/sms/invite-template.txt");
|
||||
getGeneric().put("matrixId", "classpath:/threepids/email/mxid-template.eml");
|
||||
getSession().getValidation().setLocal("classpath:/threepids/sms/validate-local-template.txt");
|
||||
getSession().getValidation().setRemote("classpath:/threepids/sms/validate-remote-template.txt");
|
||||
}
|
||||
|
||||
public PhoneSmsTemplateConfig build() {
|
||||
|
||||
@@ -27,11 +27,16 @@ import io.kamax.mxisd.config.threepid.medium.GenericTemplateConfig;
|
||||
import io.kamax.mxisd.exception.InternalServerError;
|
||||
import io.kamax.mxisd.invitation.IThreePidInviteReply;
|
||||
import io.kamax.mxisd.threepid.session.IThreePidSession;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public abstract class GenericTemplateNotificationGenerator extends PlaceholderNotificationGenerator implements NotificationGenerator {
|
||||
|
||||
@@ -46,13 +51,14 @@ public abstract class GenericTemplateNotificationGenerator extends PlaceholderNo
|
||||
|
||||
private String getTemplateContent(String location) {
|
||||
try {
|
||||
// FIXME make it work again
|
||||
/*
|
||||
InputStream is = StringUtils.startsWith(location, "classpath:") ?
|
||||
app.getResource(location).getInputStream() : new FileInputStream(location);
|
||||
URI loc = URI.create(location);
|
||||
InputStream is;
|
||||
if (StringUtils.equals("classpath", loc.getScheme())) {
|
||||
is = getClass().getResourceAsStream(loc.getSchemeSpecificPart());
|
||||
} else {
|
||||
is = new FileInputStream(location);
|
||||
}
|
||||
return IOUtils.toString(is, StandardCharsets.UTF_8);
|
||||
*/
|
||||
throw new IOException("Not implemented!");
|
||||
} catch (IOException e) {
|
||||
throw new InternalServerError("Unable to read template content at " + location + ": " + e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user