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
|
```yaml
|
||||||
directory.exclude.homeserver: true
|
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.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConfigurationProperties("directory")
|
@ConfigurationProperties("directory")
|
||||||
public class DirectoryConfig {
|
public class DirectoryConfig {
|
||||||
@@ -34,6 +36,7 @@ public class DirectoryConfig {
|
|||||||
public static class Exclude {
|
public static class Exclude {
|
||||||
|
|
||||||
private boolean homeserver;
|
private boolean homeserver;
|
||||||
|
private boolean threepid;
|
||||||
|
|
||||||
public boolean getHomeserver() {
|
public boolean getHomeserver() {
|
||||||
return homeserver;
|
return homeserver;
|
||||||
@@ -44,6 +47,14 @@ public class DirectoryConfig {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getThreepid() {
|
||||||
|
return threepid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThreepid(boolean threepid) {
|
||||||
|
this.threepid = threepid;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Exclude exclude = new Exclude();
|
private Exclude exclude = new Exclude();
|
||||||
@@ -56,4 +67,12 @@ public class DirectoryConfig {
|
|||||||
this.exclude = exclude;
|
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,6 +129,9 @@ public class DirectoryManager {
|
|||||||
result.setLimited(true);
|
result.setLimited(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cfg.getExclude().getThreepid()) {
|
||||||
|
log.info("Skipping 3PID data, disabled in config");
|
||||||
|
} else {
|
||||||
resultProvider = provider.searchBy3pid(query);
|
resultProvider = provider.searchBy3pid(query);
|
||||||
log.info("Threepid: found {} match(es) for '{}'", resultProvider.getResults().size(), query);
|
log.info("Threepid: found {} match(es) for '{}'", resultProvider.getResults().size(), query);
|
||||||
result.getResults().addAll(resultProvider.getResults());
|
result.getResults().addAll(resultProvider.getResults());
|
||||||
@@ -136,6 +139,7 @@ public class DirectoryManager {
|
|||||||
result.setLimited(true);
|
result.setLimited(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.info("Total matches: {} - limited? {}", result.getResults().size(), result.isLimited());
|
log.info("Total matches: {} - limited? {}", result.getResults().size(), result.isLimited());
|
||||||
return result;
|
return result;
|
||||||
|
Reference in New Issue
Block a user