Search in sources :

Example 6 with Mxisd

use of io.kamax.mxisd.Mxisd in project mxisd by kamax-io.

the class EmailNotificationTest method before.

@Before
public void before() {
    EmailSmtpConfig smtpCfg = new EmailSmtpConfig();
    smtpCfg.setPort(3025);
    smtpCfg.setLogin(user);
    smtpCfg.setPassword(user);
    EmailConfig eCfg = new EmailConfig();
    eCfg.setConnector(EmailSmtpConnector.ID);
    eCfg.getIdentity().setFrom(sender);
    eCfg.getIdentity().setName(senderName);
    eCfg.getConnectors().put(EmailSmtpConnector.ID, GsonUtil.makeObj(smtpCfg));
    MxisdConfig cfg = new MxisdConfig();
    cfg.getMatrix().setDomain(domain);
    cfg.getKey().setPath(":memory:");
    cfg.getStorage().getProvider().getSqlite().setDatabase(":memory:");
    cfg.getThreepid().getMedium().put(ThreePidMedium.Email.getId(), GsonUtil.makeObj(eCfg));
    m = new Mxisd(cfg);
    m.start();
    gm = new GreenMail(ServerSetupTest.SMTP_IMAP);
    gm.start();
}
Also used : MxisdConfig(io.kamax.mxisd.config.MxisdConfig) EmailConfig(io.kamax.mxisd.config.threepid.medium.EmailConfig) GreenMail(com.icegreen.greenmail.util.GreenMail) Mxisd(io.kamax.mxisd.Mxisd) EmailSmtpConfig(io.kamax.mxisd.config.threepid.connector.EmailSmtpConfig) Before(org.junit.Before)

Example 7 with Mxisd

use of io.kamax.mxisd.Mxisd in project mxisd by kamax-io.

the class MxisdDefaultTest method defaultConfig.

@Test
public void defaultConfig() {
    MxisdConfig cfg = MxisdConfig.forDomain(domain).inMemory();
    Mxisd m = new Mxisd(cfg);
    m.start();
    assertNotNull(m.getConfig());
    assertEquals(domain, m.getConfig().getMatrix().getDomain());
    assertTrue(m.getNotif().isMediumSupported(ThreePidMedium.Email.getId()));
    assertTrue(m.getNotif().isMediumSupported(ThreePidMedium.PhoneNumber.getId()));
}
Also used : MxisdConfig(io.kamax.mxisd.config.MxisdConfig) Mxisd(io.kamax.mxisd.Mxisd) Test(org.junit.Test)

Example 8 with Mxisd

use of io.kamax.mxisd.Mxisd 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

Mxisd (io.kamax.mxisd.Mxisd)8 MxisdConfig (io.kamax.mxisd.config.MxisdConfig)4 EmailConfig (io.kamax.mxisd.config.threepid.medium.EmailConfig)4 GsonUtil (io.kamax.matrix.json.GsonUtil)3 List (java.util.List)3 Optional (java.util.Optional)3 JsonSyntaxException (com.google.gson.JsonSyntaxException)2 ThreePidMedium (io.kamax.matrix.ThreePidMedium)2 MemoryIdentityConfig (io.kamax.mxisd.config.memory.MemoryIdentityConfig)2 MemoryThreePid (io.kamax.mxisd.config.memory.MemoryThreePid)2 EmailSendGridConfig (io.kamax.mxisd.config.threepid.connector.EmailSendGridConfig)2 PhoneConfig (io.kamax.mxisd.config.threepid.medium.PhoneConfig)2 ConfigurationException (io.kamax.mxisd.exception.ConfigurationException)2 NotificationHandlerSupplier (io.kamax.mxisd.notification.NotificationHandlerSupplier)2 NotificationHandlers (io.kamax.mxisd.notification.NotificationHandlers)2 EmailConnector (io.kamax.mxisd.threepid.connector.email.EmailConnector)2 EmailConnectorSupplier (io.kamax.mxisd.threepid.connector.email.EmailConnectorSupplier)2 PhoneConnector (io.kamax.mxisd.threepid.connector.phone.PhoneConnector)2 PhoneConnectorSupplier (io.kamax.mxisd.threepid.connector.phone.PhoneConnectorSupplier)2 EmailGenerator (io.kamax.mxisd.threepid.generator.email.EmailGenerator)2