Further work
This commit is contained in:
@@ -26,14 +26,13 @@ import io.kamax.mxisd.config.DnsOverwrite;
|
||||
import io.kamax.mxisd.config.DnsOverwriteEntry;
|
||||
import io.kamax.mxisd.exception.BadRequestException;
|
||||
import io.kamax.mxisd.exception.MappingAlreadyExistsException;
|
||||
import io.kamax.mxisd.invitation.generator.IInviteContentGenerator;
|
||||
import io.kamax.mxisd.lookup.SingleLookupReply;
|
||||
import io.kamax.mxisd.lookup.ThreePidMapping;
|
||||
import io.kamax.mxisd.lookup.strategy.LookupStrategy;
|
||||
import io.kamax.mxisd.notification.NotificationManager;
|
||||
import io.kamax.mxisd.signature.SignatureManager;
|
||||
import io.kamax.mxisd.storage.IStorage;
|
||||
import io.kamax.mxisd.storage.ormlite.ThreePidInviteIO;
|
||||
import io.kamax.mxisd.threepid.connector.IThreePidConnector;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.RandomStringUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -84,35 +83,15 @@ public class InvitationManager {
|
||||
@Autowired
|
||||
private DnsOverwrite dns;
|
||||
|
||||
private Map<String, IInviteContentGenerator> generators;
|
||||
private Map<String, IThreePidConnector> connectors;
|
||||
private NotificationManager notifMgr;
|
||||
|
||||
private CloseableHttpClient client;
|
||||
private Gson gson;
|
||||
private Timer refreshTimer;
|
||||
|
||||
@Autowired
|
||||
public InvitationManager(
|
||||
List<IInviteContentGenerator> generatorList,
|
||||
List<IThreePidConnector> connectorList
|
||||
) {
|
||||
generators = new HashMap<>();
|
||||
generatorList.forEach(sender -> { // FIXME to support several possible implementations
|
||||
if (generators.containsKey(sender.getMedium())) {
|
||||
throw new RuntimeException("More than one " + sender.getMedium() + " content generator");
|
||||
}
|
||||
|
||||
generators.put(sender.getMedium(), sender);
|
||||
});
|
||||
|
||||
connectors = new HashMap<>();
|
||||
connectorList.forEach(connector -> { // FIXME to support several possible implementations
|
||||
if (connectors.containsKey(connector.getMedium())) {
|
||||
throw new RuntimeException("More than one " + connector.getMedium() + " connector");
|
||||
}
|
||||
|
||||
connectors.put(connector.getMedium(), connector);
|
||||
});
|
||||
public InvitationManager(NotificationManager notifMgr) {
|
||||
this.notifMgr = notifMgr;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
@@ -221,9 +200,7 @@ public class InvitationManager {
|
||||
}
|
||||
|
||||
public synchronized IThreePidInviteReply storeInvite(IThreePidInvite invitation) { // TODO better sync
|
||||
IInviteContentGenerator generator = generators.get(invitation.getMedium());
|
||||
IThreePidConnector connector = connectors.get(invitation.getMedium());
|
||||
if (generator == null || connector == null) {
|
||||
if (!notifMgr.isMediumSupported(invitation.getMedium())) {
|
||||
throw new BadRequestException("Medium type " + invitation.getMedium() + " is not supported");
|
||||
}
|
||||
|
||||
@@ -246,7 +223,7 @@ public class InvitationManager {
|
||||
IThreePidInviteReply reply = new ThreePidInviteReply(invId, invitation, token, displayName);
|
||||
|
||||
log.info("Performing invite to {}:{}", invitation.getMedium(), invitation.getAddress());
|
||||
connector.send(reply, generator.generate(reply));
|
||||
notifMgr.send(reply);
|
||||
|
||||
log.info("Storing invite under ID {}", invId);
|
||||
storage.insertInvite(reply);
|
||||
|
||||
Reference in New Issue
Block a user