Add on/off switch for 3PID in directory lookups
This commit is contained in:
@@ -140,3 +140,10 @@ To disable Homeserver results, set the following in mxisd configuration file:
|
||||
```yaml
|
||||
directory.exclude.homeserver: true
|
||||
```
|
||||
|
||||
### 3PID exclusion in search
|
||||
You can configure if the 3PID should also be included when doing a directory search.
|
||||
By default, a search is performed on the 3PIDs. If you would like to not include them:
|
||||
```yaml
|
||||
directory.exclude.threepid: true
|
||||
```
|
||||
|
@@ -25,6 +25,8 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties("directory")
|
||||
public class DirectoryConfig {
|
||||
@@ -34,6 +36,7 @@ public class DirectoryConfig {
|
||||
public static class Exclude {
|
||||
|
||||
private boolean homeserver;
|
||||
private boolean threepid;
|
||||
|
||||
public boolean getHomeserver() {
|
||||
return homeserver;
|
||||
@@ -44,6 +47,14 @@ public class DirectoryConfig {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getThreepid() {
|
||||
return threepid;
|
||||
}
|
||||
|
||||
public void setThreepid(boolean threepid) {
|
||||
this.threepid = threepid;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Exclude exclude = new Exclude();
|
||||
@@ -56,4 +67,12 @@ public class DirectoryConfig {
|
||||
this.exclude = exclude;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void buid() {
|
||||
log.info("--- Directory config ---");
|
||||
log.info("Exclude:");
|
||||
log.info("\tHomeserver: {}", getExclude().getHomeserver());
|
||||
log.info("\t3PID: {}", getExclude().getThreepid());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -129,11 +129,15 @@ public class DirectoryManager {
|
||||
result.setLimited(true);
|
||||
}
|
||||
|
||||
resultProvider = provider.searchBy3pid(query);
|
||||
log.info("Threepid: found {} match(es) for '{}'", resultProvider.getResults().size(), query);
|
||||
result.getResults().addAll(resultProvider.getResults());
|
||||
if (resultProvider.isLimited()) {
|
||||
result.setLimited(true);
|
||||
if (cfg.getExclude().getThreepid()) {
|
||||
log.info("Skipping 3PID data, disabled in config");
|
||||
} else {
|
||||
resultProvider = provider.searchBy3pid(query);
|
||||
log.info("Threepid: found {} match(es) for '{}'", resultProvider.getResults().size(), query);
|
||||
result.getResults().addAll(resultProvider.getResults());
|
||||
if (resultProvider.isLimited()) {
|
||||
result.setLimited(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user