added setup command which includes an interactive process in order to setup features

the current supported features are post targets and system config
the wizard includes a summary step where the user can confirm the changes
removed some unnecessary validators, which were basically just validating the system config from some features
fixed post target name
This commit is contained in:
Sheldan
2020-05-22 17:25:44 +02:00
parent e2f71ef7a3
commit 992357b2cb
81 changed files with 1074 additions and 92 deletions

View File

@@ -44,7 +44,7 @@ public class MyWarnings extends AbstractConditionableCommand {
model.setCurrentWarnCount(currentWarnCount);
Long totalWarnCount = warnManagementService.getTotalWarnsForUser(commandContext.getUserInitiatedContext().getAUserInAServer());
model.setTotalWarnCount(totalWarnCount);
channelService.sendTemplateInChannel("myWarnings_response", model, commandContext.getChannel());
channelService.sendEmbedTemplateInChannel("myWarnings_response", model, commandContext.getChannel());
return CommandResult.fromSuccess();
}

View File

@@ -63,7 +63,7 @@ public class UserNotes extends AbstractConditionableCommand {
userNotes = userNoteManagementService.loadNotesForServer(commandContext.getUserInitiatedContext().getServer());
}
model.setUserNotes(userNotesConverter.fromNotes(userNotes));
channelService.sendTemplateInChannel("user_notes_response", model, commandContext.getChannel());
channelService.sendEmbedTemplateInChannel("user_notes_response", model, commandContext.getChannel());
return CommandResult.fromSuccess();
}

View File

@@ -1,20 +0,0 @@
package dev.sheldan.abstracto.moderation.validator;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.models.FeatureValidationResult;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.FeatureValidatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class WarnDecayFeatureValidatorBean implements WarnDecayFeatureValidator {
@Autowired
private FeatureValidatorService featureValidatorService;
@Override
public void featureIsSetup(FeatureConfig featureConfig, AServer server, FeatureValidationResult validationResult) {
featureValidatorService.checkSystemConfig("decayDays", server, validationResult);
}
}

View File

@@ -3,9 +3,7 @@ package dev.sheldan.abstracto.moderation.config.features;
import dev.sheldan.abstracto.core.config.FeatureConfig;
import dev.sheldan.abstracto.core.config.FeatureEnum;
import dev.sheldan.abstracto.core.config.PostTargetEnum;
import dev.sheldan.abstracto.core.service.FeatureValidator;
import dev.sheldan.abstracto.moderation.config.posttargets.WarnDecayPostTarget;
import dev.sheldan.abstracto.moderation.validator.WarnDecayFeatureValidator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -18,14 +16,17 @@ public class WarningDecayFeature implements FeatureConfig {
@Autowired
private WarningFeature warningFeature;
@Autowired
private WarnDecayFeatureValidator warnDecayFeatureValidator;
@Override
public FeatureEnum getFeature() {
return ModerationFeatures.AUTOMATIC_WARN_DECAY;
}
@Override
public List<String> getRequiredSystemConfigKeys() {
return Arrays.asList("decayDays");
}
@Override
public List<FeatureConfig> getRequiredFeatures() {
return Arrays.asList(warningFeature);
@@ -36,8 +37,4 @@ public class WarningDecayFeature implements FeatureConfig {
return Arrays.asList(WarnDecayPostTarget.DECAY_LOG);
}
@Override
public List<FeatureValidator> getAdditionalFeatureValidators() {
return Arrays.asList(warnDecayFeatureValidator);
}
}

View File

@@ -5,7 +5,7 @@ import lombok.Getter;
@Getter
public enum LoggingPostTarget implements PostTargetEnum {
LEAVE_LOG("muteLog"), JOIN_LOG("joinLog"), DELETE_LOG("deleteLog"), EDIT_LOG("editLog");
LEAVE_LOG("leaveLog"), JOIN_LOG("joinLog"), DELETE_LOG("deleteLog"), EDIT_LOG("editLog");
private String key;

View File

@@ -1,6 +0,0 @@
package dev.sheldan.abstracto.moderation.validator;
import dev.sheldan.abstracto.core.service.FeatureValidator;
public interface WarnDecayFeatureValidator extends FeatureValidator {
}