Only sort providers once
This commit is contained in:
@@ -21,21 +21,18 @@
|
|||||||
package io.kamax.mxisd.lookup
|
package io.kamax.mxisd.lookup
|
||||||
|
|
||||||
import io.kamax.mxisd.api.ThreePidType
|
import io.kamax.mxisd.api.ThreePidType
|
||||||
|
import org.springframework.beans.factory.InitializingBean
|
||||||
import org.springframework.beans.factory.annotation.Autowired
|
import org.springframework.beans.factory.annotation.Autowired
|
||||||
import org.springframework.stereotype.Component
|
import org.springframework.stereotype.Component
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
class PriorityLookupStrategy implements LookupStrategy {
|
class PriorityLookupStrategy implements LookupStrategy, InitializingBean {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private List<ThreePidProvider> providers
|
private List<ThreePidProvider> providers
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Optional<?> find(ThreePidType type, String threePid) {
|
void afterPropertiesSet() throws Exception {
|
||||||
if (ThreePidType.email != type) {
|
|
||||||
throw new IllegalArgumentException("${type} is currently not supported")
|
|
||||||
}
|
|
||||||
|
|
||||||
providers.sort(new Comparator<ThreePidProvider>() {
|
providers.sort(new Comparator<ThreePidProvider>() {
|
||||||
|
|
||||||
@Override
|
@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) {
|
for (ThreePidProvider provider : providers) {
|
||||||
Optional<?> lookupDataOpt = provider.find(type, threePid)
|
Optional<?> lookupDataOpt = provider.find(type, threePid)
|
||||||
|
|||||||
Reference in New Issue
Block a user