Remove 3PID type limitation
This commit is contained in:
@@ -20,18 +20,16 @@
|
||||
|
||||
package io.kamax.mxisd.lookup
|
||||
|
||||
import io.kamax.mxisd.api.ThreePidType
|
||||
|
||||
class SingleLookupRequest extends ALookupRequest {
|
||||
|
||||
private ThreePidType type
|
||||
private String type
|
||||
private String threePid
|
||||
|
||||
ThreePidType getType() {
|
||||
String getType() {
|
||||
return type
|
||||
}
|
||||
|
||||
void setType(ThreePidType type) {
|
||||
void setType(String type) {
|
||||
this.type = type
|
||||
}
|
||||
|
||||
|
||||
@@ -74,4 +74,5 @@ public class ThreePidMapping {
|
||||
public String toString() {
|
||||
return JsonOutput.toJson(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
package io.kamax.mxisd.lookup.provider
|
||||
|
||||
import io.kamax.mxisd.api.ThreePidType
|
||||
import io.kamax.mxisd.config.ServerConfig
|
||||
import io.kamax.mxisd.lookup.SingleLookupRequest
|
||||
import io.kamax.mxisd.lookup.ThreePidMapping
|
||||
@@ -112,12 +111,13 @@ class DnsLookupProvider extends RemoteIdentityServerProvider {
|
||||
|
||||
@Override
|
||||
Optional<?> find(SingleLookupRequest request) {
|
||||
log.info("Performing DNS lookup for {}", request.getThreePid())
|
||||
if (ThreePidType.email != request.getType()) {
|
||||
if (!StringUtils.equals("email", request.getType())) { // TODO use enum
|
||||
log.info("Skipping unsupported type {} for {}", request.getType(), request.getThreePid())
|
||||
return Optional.empty()
|
||||
}
|
||||
|
||||
log.info("Performing DNS lookup for {}", request.getThreePid())
|
||||
|
||||
String domain = request.getThreePid().substring(request.getThreePid().lastIndexOf("@") + 1)
|
||||
log.info("Domain name for {}: {}", request.getThreePid(), domain)
|
||||
Optional<String> baseUrl = findIdentityServerForDomain(domain)
|
||||
@@ -134,7 +134,7 @@ class DnsLookupProvider extends RemoteIdentityServerProvider {
|
||||
Map<String, List<ThreePidMapping>> domains = new HashMap<>()
|
||||
|
||||
for (ThreePidMapping mapping : mappings) {
|
||||
if (!StringUtils.equals(mapping.getMedium(), ThreePidType.email.toString())) {
|
||||
if (!StringUtils.equals("email", mapping.getMedium())) {
|
||||
log.info("Skipping unsupported type {} for {}", mapping.getMedium(), mapping.getValue())
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
package io.kamax.mxisd.lookup.provider
|
||||
|
||||
import io.kamax.mxisd.api.ThreePidType
|
||||
import io.kamax.mxisd.config.LdapConfig
|
||||
import io.kamax.mxisd.config.ServerConfig
|
||||
import io.kamax.mxisd.lookup.SingleLookupRequest
|
||||
@@ -61,7 +60,7 @@ class LdapProvider implements ThreePidProvider {
|
||||
return 20
|
||||
}
|
||||
|
||||
Optional<String> lookup(LdapConnection conn, ThreePidType medium, String value) {
|
||||
Optional<String> lookup(LdapConnection conn, String medium, String value) {
|
||||
Optional<String> queryOpt = ldapCfg.getMapping(medium)
|
||||
if (!queryOpt.isPresent()) {
|
||||
log.warn("{} is not a supported 3PID type for LDAP lookup", medium)
|
||||
@@ -142,8 +141,7 @@ class LdapProvider implements ThreePidProvider {
|
||||
|
||||
for (ThreePidMapping mapping : mappings) {
|
||||
try {
|
||||
ThreePidType type = ThreePidType.valueOf(mapping.getMedium())
|
||||
Optional<String> mxid = lookup(conn, type, mapping.getValue())
|
||||
Optional<String> mxid = lookup(conn, mapping.getMedium(), mapping.getValue())
|
||||
if (mxid.isPresent()) {
|
||||
mapping.setMxid(mxid.get())
|
||||
mappingsFound.add(mapping)
|
||||
|
||||
@@ -23,7 +23,6 @@ package io.kamax.mxisd.lookup.provider
|
||||
import groovy.json.JsonException
|
||||
import groovy.json.JsonOutput
|
||||
import groovy.json.JsonSlurper
|
||||
import io.kamax.mxisd.api.ThreePidType
|
||||
import io.kamax.mxisd.controller.v1.ClientBulkLookupRequest
|
||||
import io.kamax.mxisd.lookup.ThreePidMapping
|
||||
import org.apache.http.HttpEntity
|
||||
@@ -94,7 +93,7 @@ abstract class RemoteIdentityServerProvider implements ThreePidProvider {
|
||||
return Optional.empty()
|
||||
}
|
||||
|
||||
Optional<?> find(String remote, ThreePidType type, String threePid) {
|
||||
Optional<?> find(String remote, String type, String threePid) {
|
||||
log.info("Looking up {} 3PID {} using {}", type, threePid, remote)
|
||||
|
||||
HttpURLConnection rootSrvConn = (HttpURLConnection) new URL(
|
||||
|
||||
Reference in New Issue
Block a user