use of io.kamax.mxisd.threepid.connector.phone.PhoneConnector in project mxisd by kamax-io.
the class BuiltInNotificationHandlerSupplier method acceptPhone.
private void acceptPhone(String handler, Mxisd mxisd) {
if (StringUtils.equals(PhoneNotificationHandler.ID, handler)) {
Object o = mxisd.getConfig().getThreepid().getMedium().get(ThreePidMedium.PhoneNumber.getId());
if (Objects.nonNull(o)) {
PhoneConfig cfg;
try {
cfg = GsonUtil.get().fromJson(GsonUtil.makeObj(o), PhoneConfig.class);
} catch (JsonSyntaxException e) {
throw new ConfigurationException("Invalid configuration for threepid msisdn notification");
}
List<PhoneGenerator> generators = StreamSupport.stream(ServiceLoader.load(PhoneGeneratorSupplier.class).spliterator(), false).map(s -> s.apply(cfg, mxisd)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
List<PhoneConnector> connectors = StreamSupport.stream(ServiceLoader.load(PhoneConnectorSupplier.class).spliterator(), false).map(s -> s.apply(cfg, mxisd)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
NotificationHandlers.register(() -> new PhoneNotificationHandler(cfg, generators, connectors));
}
}
}
Aggregations