Refactor logic, preparing to generalize post-login publish of mappings
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user