mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-16 12:28:03 +00:00
moved post targets to an enum, in order to have more type safety, this might be changed in the future
added validation check when a feature is enabled, in order to notify which configuration is missing for this feature to function properly
This commit is contained in:
@@ -2,8 +2,13 @@ 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.moderation.config.posttargets.LoggingPostTarget;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class LoggingFeature implements FeatureConfig {
|
||||
|
||||
@@ -12,4 +17,9 @@ public class LoggingFeature implements FeatureConfig {
|
||||
return ModerationFeatures.LOGGING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(LoggingPostTarget.DELETE_LOG, LoggingPostTarget.EDIT_LOG, LoggingPostTarget.JOIN_LOG, LoggingPostTarget.LEAVE_LOG);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -2,8 +2,13 @@ package dev.sheldan.abstracto.moderation.config.features;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.config.FeatureConfig;
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import dev.sheldan.abstracto.moderation.config.posttargets.ModerationPostTarget;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class ModerationFeature implements FeatureConfig {
|
||||
|
||||
@@ -12,4 +17,8 @@ public class ModerationFeature implements FeatureConfig {
|
||||
return ModerationFeatures.MODERATION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(ModerationPostTarget.BAN_LOG, ModerationPostTarget.KICK_LOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,13 @@ 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.moderation.config.posttargets.MutingPostTarget;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class MutingFeature implements FeatureConfig {
|
||||
|
||||
@@ -12,4 +17,8 @@ public class MutingFeature implements FeatureConfig {
|
||||
return ModerationFeatures.MUTING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(MutingPostTarget.MUTE_LOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ 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.moderation.config.posttargets.WarnDecayPostTarget;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -23,4 +25,9 @@ public class WarningDecayFeature implements FeatureConfig {
|
||||
public List<FeatureConfig> getRequiredFeatures() {
|
||||
return Arrays.asList(warningFeature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(WarnDecayPostTarget.DECAY_LOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ 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.moderation.config.posttargets.WarningPostTarget;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@@ -23,4 +25,9 @@ public class WarningFeature implements FeatureConfig {
|
||||
public List<FeatureConfig> getDependantFeatures() {
|
||||
return Arrays.asList(warningDecayFeature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PostTargetEnum> getRequiredPostTargets() {
|
||||
return Arrays.asList(WarningPostTarget.WARN_LOG);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.abstracto.moderation.config.posttargets;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum LoggingPostTarget implements PostTargetEnum {
|
||||
LEAVE_LOG("muteLog"), JOIN_LOG("joinLog"), DELETE_LOG("deleteLog"), EDIT_LOG("editLog");
|
||||
|
||||
private String key;
|
||||
|
||||
LoggingPostTarget(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.moderation.config.posttargets;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ModerationPostTarget implements PostTargetEnum {
|
||||
KICK_LOG("kickLog"), BAN_LOG("banLog");
|
||||
|
||||
private String key;
|
||||
|
||||
ModerationPostTarget(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.moderation.config.posttargets;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum MutingPostTarget implements PostTargetEnum {
|
||||
MUTE_LOG("muteLog");
|
||||
|
||||
private String key;
|
||||
|
||||
MutingPostTarget(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.moderation.config.posttargets;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum WarnDecayPostTarget implements PostTargetEnum {
|
||||
DECAY_LOG("decayLog");
|
||||
|
||||
private String key;
|
||||
|
||||
WarnDecayPostTarget(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package dev.sheldan.abstracto.moderation.config.posttargets;
|
||||
|
||||
import dev.sheldan.abstracto.core.config.PostTargetEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum WarningPostTarget implements PostTargetEnum {
|
||||
WARN_LOG("warnLog");
|
||||
|
||||
private String key;
|
||||
|
||||
WarningPostTarget(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user