Search in sources :

Example 1 with EmailTemplateConfig

use of io.kamax.mxisd.config.threepid.medium.EmailTemplateConfig in project mxisd by kamax-io.

the class BuiltInEmailGeneratorSupplier method apply.

@Override
public Optional<EmailGenerator> apply(EmailConfig emailConfig, Mxisd mxisd) {
    if (!processed) {
        if (StringUtils.equals(GenericEmailNotificationGenerator.ID, emailConfig.getGenerator())) {
            EmailTemplateConfig cfg = Optional.ofNullable(emailConfig.getGenerators().get(GenericEmailNotificationGenerator.ID)).map(json -> GsonUtil.get().fromJson(json, EmailTemplateConfig.class)).orElseGet(EmailTemplateConfig::new);
            obj = new GenericEmailNotificationGenerator(cfg, emailConfig, mxisd.getConfig().getMatrix(), mxisd.getConfig().getServer());
        }
    }
    processed = true;
    return Optional.ofNullable(obj);
}
Also used : EmailConfig(io.kamax.mxisd.config.threepid.medium.EmailConfig) GsonUtil(io.kamax.matrix.json.GsonUtil) StringUtils(org.apache.commons.lang.StringUtils) EmailTemplateConfig(io.kamax.mxisd.config.threepid.medium.EmailTemplateConfig) Optional(java.util.Optional) Mxisd(io.kamax.mxisd.Mxisd) EmailTemplateConfig(io.kamax.mxisd.config.threepid.medium.EmailTemplateConfig)

Aggregations

GsonUtil (io.kamax.matrix.json.GsonUtil)1 Mxisd (io.kamax.mxisd.Mxisd)1 EmailConfig (io.kamax.mxisd.config.threepid.medium.EmailConfig)1 EmailTemplateConfig (io.kamax.mxisd.config.threepid.medium.EmailTemplateConfig)1 Optional (java.util.Optional)1 StringUtils (org.apache.commons.lang.StringUtils)1