Refactor logic, preparing to generalize post-login publish of mappings

This commit is contained in:
Maxime Dor
2017-09-12 19:47:01 +02:00
parent 55b759a31c
commit 09b789dfc2
10 changed files with 151 additions and 91 deletions

View File

@@ -21,6 +21,7 @@
package io.kamax.mxisd.lookup;
import groovy.json.JsonOutput;
import io.kamax.mxisd.ThreePid;
public class ThreePidMapping {
@@ -32,6 +33,10 @@ public class ThreePidMapping {
// stub
}
public ThreePidMapping(ThreePid threePid, String mxid) {
this(threePid.getMedium(), threePid.getAddress(), mxid);
}
public ThreePidMapping(String medium, String value, String mxid) {
setMedium(medium);
setValue(value);

View File

@@ -60,7 +60,7 @@ public class GoogleFirebaseProvider implements IThreePidProvider {
this(true);
this.domain = domain;
try {
fbApp = FirebaseApp.initializeApp(getOpts(credsPath, db));
fbApp = FirebaseApp.initializeApp(getOpts(credsPath, db), "ThreePidProvider");
fbAuth = FirebaseAuth.getInstance(fbApp);
log.info("Google Firebase Authentication is ready");

View File

@@ -29,6 +29,8 @@ interface LookupStrategy {
List<IThreePidProvider> getLocalProviders()
Optional<?> find(String medium, String address, boolean recursive)
Optional<?> find(SingleLookupRequest request)
Optional<?> findRecursive(SingleLookupRequest request)

View File

@@ -121,6 +121,16 @@ class RecursivePriorityLookupStrategy implements LookupStrategy, InitializingBea
}).collect(Collectors.toList())
}
@Override
Optional<?> find(String medium, String address, boolean recursive) {
SingleLookupRequest req = new SingleLookupRequest();
req.setType(medium)
req.setThreePid(address)
req.setRequester("Internal")
return find(req, recursive)
}
@Override
Optional<?> find(SingleLookupRequest request, boolean forceRecursive) {
for (IThreePidProvider provider : listUsableProviders(request, forceRecursive)) {
Optional<?> lookupDataOpt = provider.find(request)