mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-26 05:44:42 +00:00
added dynamic post target loading
fixed some templates of commands added fat jar maven config
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
package dev.sheldan.abstracto.core;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Getter
|
||||
@Setter
|
||||
@PropertySource("classpath:abstracto.properties")
|
||||
@ConfigurationProperties(prefix = "abstracto")
|
||||
public class PostTargetLoader {
|
||||
|
||||
private HashMap<String, String> postTargets = new HashMap<>();
|
||||
|
||||
public List<String> getPostTargetsAsList() {
|
||||
List<String> targets = new ArrayList<>();
|
||||
if(postTargets == null || postTargets.size() == 0) {
|
||||
return targets;
|
||||
}
|
||||
postTargets.values().forEach(s -> targets.addAll(Arrays.asList(s.split(","))));
|
||||
return targets;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class Ping implements Command {
|
||||
|
||||
public static final String PING_TEMPLATE = "ping";
|
||||
public static final String PING_TEMPLATE = "ping_response";
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.service.management;
|
||||
|
||||
import dev.sheldan.abstracto.core.PostTargetLoader;
|
||||
import dev.sheldan.abstracto.core.exception.PostTargetException;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
@@ -25,9 +26,12 @@ public class PostTargetManagementBean implements PostTargetManagement {
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Autowired
|
||||
private PostTargetLoader postTargetLoader;
|
||||
|
||||
@Override
|
||||
public void createPostTarget(String name, AServer server, AChannel targetChannel) {
|
||||
if(!PostTarget.AVAILABLE_POST_TARGETS.contains(name)) {
|
||||
if(!postTargetLoader.getPostTargetsAsList().contains(name)) {
|
||||
throw new PostTargetException("PostTarget not found");
|
||||
}
|
||||
log.info("Creating post target {} pointing towards {}", name, targetChannel);
|
||||
|
||||
Reference in New Issue
Block a user