Add mechanisms for 3PID invite expiration and AS integration

- Integration with AS and a fallback user to decline expired invites (#120)
- Rework of the AS feature to make it more independent/re-usable
- Skeleton for admin interface via bot to manage invites (#138)
This commit is contained in:
Max Dor
2019-03-02 03:19:47 +01:00
parent de92e98f7d
commit 254dc5684f
15 changed files with 771 additions and 353 deletions

View File

@@ -20,7 +20,7 @@
package io.kamax.mxisd.as;
import io.kamax.mxisd.config.ListenerConfig;
import io.kamax.mxisd.config.AppServiceConfig;
import java.net.URL;
import java.util.ArrayList;
@@ -29,20 +29,28 @@ import java.util.Objects;
public class SynapseRegistrationYaml {
public static SynapseRegistrationYaml parse(ListenerConfig cfg) {
public static SynapseRegistrationYaml parse(AppServiceConfig cfg, String domain) {
SynapseRegistrationYaml yaml = new SynapseRegistrationYaml();
yaml.setId("appservice-mxisd");
yaml.setUrl(cfg.getUrl());
yaml.setAsToken(cfg.getToken().getAs());
yaml.setHsToken(cfg.getToken().getHs());
yaml.setSenderLocalpart(cfg.getLocalpart());
cfg.getUsers().forEach(template -> {
yaml.setId(cfg.getRegistration().getSynapse().getId());
yaml.setUrl(cfg.getEndpoint().getToAS().getUrl());
yaml.setAsToken(cfg.getEndpoint().getToHS().getToken());
yaml.setHsToken(cfg.getEndpoint().getToAS().getToken());
yaml.setSenderLocalpart(cfg.getUser().getMain());
if (cfg.getFeature().getCleanExpiredInvite()) {
Namespace ns = new Namespace();
ns.setRegex(template.getTemplate());
ns.setExclusive(true);
ns.setRegex("@" + cfg.getUser().getInviteExpired() + ":" + domain);
yaml.getNamespaces().getUsers().add(ns);
});
}
if (cfg.getFeature().getInviteById()) {
Namespace ns = new Namespace();
ns.setExclusive(false);
ns.setRegex("@*:" + domain);
yaml.getNamespaces().getUsers().add(ns);
}
return yaml;
}