Skeleton for invitation policies (#130)
This commit is contained in:
@@ -20,13 +20,16 @@
|
||||
|
||||
package io.kamax.mxisd.config;
|
||||
|
||||
import io.kamax.mxisd.util.GsonUtil;
|
||||
import io.kamax.matrix.json.GsonUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class InvitationConfig {
|
||||
|
||||
private transient final Logger log = LoggerFactory.getLogger(InvitationConfig.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(InvitationConfig.class);
|
||||
|
||||
public static class Resolution {
|
||||
|
||||
@@ -51,7 +54,34 @@ public class InvitationConfig {
|
||||
|
||||
}
|
||||
|
||||
public static class SenderPolicy {
|
||||
|
||||
private List<String> hasRole = new ArrayList<>();
|
||||
|
||||
public List<String> getHasRole() {
|
||||
return hasRole;
|
||||
}
|
||||
|
||||
public void setHasRole(List<String> hasRole) {
|
||||
this.hasRole = hasRole;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Policies {
|
||||
|
||||
private SenderPolicy ifSender = new SenderPolicy();
|
||||
|
||||
public SenderPolicy getIfSender() {
|
||||
return ifSender;
|
||||
}
|
||||
|
||||
public void setIfSender(SenderPolicy ifSender) {
|
||||
this.ifSender = ifSender;
|
||||
}
|
||||
}
|
||||
|
||||
private Resolution resolution = new Resolution();
|
||||
private Policies policy = new Policies();
|
||||
|
||||
public Resolution getResolution() {
|
||||
return resolution;
|
||||
@@ -61,9 +91,18 @@ public class InvitationConfig {
|
||||
this.resolution = resolution;
|
||||
}
|
||||
|
||||
public Policies getPolicy() {
|
||||
return policy;
|
||||
}
|
||||
|
||||
public void setPolicy(Policies policy) {
|
||||
this.policy = policy;
|
||||
}
|
||||
|
||||
public void build() {
|
||||
log.info("--- Invite config ---");
|
||||
log.info("Resolution: {}", GsonUtil.build().toJson(resolution));
|
||||
log.info("Resolution: {}", GsonUtil.get().toJson(getResolution()));
|
||||
log.info("Policies: {}", GsonUtil.get().toJson(getPolicy()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -193,11 +193,35 @@ public abstract class SqlConfig {
|
||||
|
||||
}
|
||||
|
||||
public static class ProfileRoles {
|
||||
|
||||
private String type;
|
||||
private String query;
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getQuery() {
|
||||
return query;
|
||||
}
|
||||
|
||||
public void setQuery(String query) {
|
||||
this.query = query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class Profile {
|
||||
|
||||
private Boolean enabled;
|
||||
private ProfileDisplayName displayName = new ProfileDisplayName();
|
||||
private ProfileThreepids threepid = new ProfileThreepids();
|
||||
private ProfileRoles role = new ProfileRoles();
|
||||
|
||||
public Boolean isEnabled() {
|
||||
return enabled;
|
||||
@@ -223,6 +247,14 @@ public abstract class SqlConfig {
|
||||
this.threepid = threepid;
|
||||
}
|
||||
|
||||
public ProfileRoles getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(ProfileRoles role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean enabled;
|
||||
@@ -323,10 +355,11 @@ public abstract class SqlConfig {
|
||||
log.info("3PID mapping query: {}", getIdentity().getQuery());
|
||||
log.info("Identity medium queries: {}", GsonUtil.build().toJson(getIdentity().getMedium()));
|
||||
log.info("Profile:");
|
||||
log.info("\tEnabled: {}", getProfile().isEnabled());
|
||||
log.info(" Enabled: {}", getProfile().isEnabled());
|
||||
if (getProfile().isEnabled()) {
|
||||
log.info("\tDisplay name query: {}", getProfile().getDisplayName().getQuery());
|
||||
log.info("\tProfile 3PID query: {}", getProfile().getThreepid().getQuery());
|
||||
log.info(" Display name query: {}", getProfile().getDisplayName().getQuery());
|
||||
log.info(" Profile 3PID query: {}", getProfile().getThreepid().getQuery());
|
||||
log.info(" Role query: {}", getProfile().getRole().getQuery());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
package io.kamax.mxisd.config.sql.synapse;
|
||||
|
||||
import io.kamax.mxisd.UserIdType;
|
||||
import io.kamax.mxisd.backend.sql.synapse.SynapseQueries;
|
||||
import io.kamax.mxisd.config.sql.SqlConfig;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -48,9 +49,17 @@ public class SynapseSqlProviderConfig extends SqlConfig {
|
||||
if (StringUtils.isBlank(getProfile().getDisplayName().getQuery())) {
|
||||
getProfile().getDisplayName().setQuery(SynapseQueries.getDisplayName());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getProfile().getThreepid().getQuery())) {
|
||||
getProfile().getThreepid().setQuery(SynapseQueries.getThreepids());
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(getProfile().getRole().getType())) {
|
||||
getProfile().getRole().setType(UserIdType.MatrixID.getId());
|
||||
}
|
||||
if (StringUtils.isBlank(getProfile().getRole().getQuery())) {
|
||||
getProfile().getRole().setQuery(SynapseQueries.getRoles());
|
||||
}
|
||||
}
|
||||
|
||||
printConfig();
|
||||
|
||||
Reference in New Issue
Block a user