mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 19:56:29 +00:00
[AB-xxx] refactoring modmail to offer a feature mode to use threads instead of channels
adding various utilities for thread channels in core fixing enable feature not showing validation messages restructuring feature mode collection to be a startup listener, because postconstruct might not have the appropriate values available, and therefore not initialize the map correctly
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
@Component
|
||||
public class ModMailFeatureConfig implements FeatureConfig {
|
||||
|
||||
public static final String MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY = "modMailClosingText";
|
||||
@Autowired
|
||||
private ModMailFeatureValidator modMailFeatureValidator;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class ModMailFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(ModMailPostTargets.MOD_MAIL_PING, ModMailPostTargets.MOD_MAIL_LOG);
|
||||
return Arrays.asList(ModMailPostTargets.MOD_MAIL_PING, ModMailPostTargets.MOD_MAIL_LOG, ModMailPostTargets.MOD_MAIL_CONTAINER);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,12 +49,12 @@ public class ModMailFeatureConfig implements FeatureConfig {
|
||||
|
||||
@Override
|
||||
public List<FeatureMode> getAvailableModes() {
|
||||
return Arrays.asList(ModMailMode.LOGGING, ModMailMode.SEPARATE_MESSAGE);
|
||||
return Arrays.asList(ModMailMode.LOGGING, ModMailMode.SEPARATE_MESSAGE, ModMailMode.THREAD_CONTAINER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getRequiredSystemConfigKeys() {
|
||||
return Arrays.asList("modMailClosingText");
|
||||
return Arrays.asList(MOD_MAIL_CLOSING_TEXT_SYSTEM_CONFIG_KEY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,7 +9,7 @@ import lombok.Getter;
|
||||
*/
|
||||
@Getter
|
||||
public enum ModMailMode implements FeatureMode {
|
||||
LOGGING("log"), SEPARATE_MESSAGE("threadMessage");
|
||||
LOGGING("log"), SEPARATE_MESSAGE("threadMessage"), THREAD_CONTAINER("threadContainer");
|
||||
|
||||
private final String key;
|
||||
|
||||
|
||||
@@ -12,7 +12,11 @@ public enum ModMailPostTargets implements PostTargetEnum {
|
||||
/**
|
||||
* The channel to be used to log the contents of closed mod mail threads
|
||||
*/
|
||||
MOD_MAIL_LOG("modmailLog");
|
||||
MOD_MAIL_LOG("modmailLog"),
|
||||
/**
|
||||
* The thread used as a container for the modmail threads
|
||||
*/
|
||||
MOD_MAIL_CONTAINER("modmailContainer");
|
||||
|
||||
private String key;
|
||||
|
||||
|
||||
@@ -41,4 +41,5 @@ public class ModMailClosingHeaderModel {
|
||||
private Boolean silently;
|
||||
private User user;
|
||||
private Long serverId;
|
||||
private Long modmailThreadId;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import net.dv8tion.jda.api.entities.Member;
|
||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||
import net.dv8tion.jda.api.entities.channel.middleman.GuildMessageChannel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ModMailNotificationModel extends ServerContext {
|
||||
*/
|
||||
private List<ModMailRole> roles;
|
||||
/**
|
||||
* The {@link TextChannel} in which the mod mail thread is handled
|
||||
* The {@link GuildMessageChannel} in which the mod mail thread is handled
|
||||
*/
|
||||
private TextChannel channel;
|
||||
private GuildMessageChannel channel;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package dev.sheldan.abstracto.modmail.model.template;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.ValidationErrorModel;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class ModMailThreadContainerValidationErrorModel implements ValidationErrorModel {
|
||||
private Long currentChannelId;
|
||||
|
||||
@Override
|
||||
public String getTemplateName() {
|
||||
return "feature_setup_modmail_thread_container_not_setup";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTemplateModel() {
|
||||
return new Object();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user