diff --git a/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy b/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy index d5b2389..740b6d8 100644 --- a/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy +++ b/src/main/groovy/io/kamax/mxisd/lookup/PriorityLookupStrategy.groovy @@ -21,21 +21,18 @@ package io.kamax.mxisd.lookup import io.kamax.mxisd.api.ThreePidType +import org.springframework.beans.factory.InitializingBean import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @Component -class PriorityLookupStrategy implements LookupStrategy { +class PriorityLookupStrategy implements LookupStrategy, InitializingBean { @Autowired private List providers @Override - Optional find(ThreePidType type, String threePid) { - if (ThreePidType.email != type) { - throw new IllegalArgumentException("${type} is currently not supported") - } - + void afterPropertiesSet() throws Exception { providers.sort(new Comparator() { @Override @@ -44,6 +41,13 @@ class PriorityLookupStrategy implements LookupStrategy { } }) + } + + @Override + Optional find(ThreePidType type, String threePid) { + if (ThreePidType.email != type) { + throw new IllegalArgumentException("${type} is currently not supported") + } for (ThreePidProvider provider : providers) { Optional lookupDataOpt = provider.find(type, threePid)