mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-14 11:48:16 +00:00
[AB-xxx] adding support for automatic setup steps
reducing eventwaiter threads adding abstracto templated exception adding json validation service increasing threads for scheduling adding convenience method to retrieve users
This commit is contained in:
@@ -48,5 +48,9 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.everit-org.json-schema</groupId>
|
||||
<artifactId>org.everit.json.schema</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.config;
|
||||
|
||||
import dev.sheldan.abstracto.core.interactive.AutoDelayedAction;
|
||||
import dev.sheldan.abstracto.core.interactive.SetupStep;
|
||||
import dev.sheldan.abstracto.core.service.FeatureValidator;
|
||||
|
||||
@@ -21,4 +22,5 @@ public interface FeatureConfig extends Serializable {
|
||||
default List<String> getRequiredEmotes() { return Collections.emptyList(); }
|
||||
default List<FeatureMode> getAvailableModes() { return Collections.emptyList(); }
|
||||
default List<SetupStep> getCustomSetupSteps() { return Collections.emptyList(); }
|
||||
default List<AutoDelayedAction> getAutoSetupSteps() { return Collections.emptyList(); }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
import dev.sheldan.abstracto.core.templating.Templatable;
|
||||
|
||||
public abstract class AbstractoTemplatableException extends AbstractoRunTimeException implements Templatable {
|
||||
public AbstractoTemplatableException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public AbstractoTemplatableException() {
|
||||
}
|
||||
|
||||
public AbstractoTemplatableException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public AbstractoTemplatableException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.interactive;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.AServerChannelUserId;
|
||||
|
||||
public interface AutoDelayedAction {
|
||||
DelayedActionConfig getDelayedActionConfig(AServerChannelUserId aServerChannelUserId);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package dev.sheldan.abstracto.core.models;
|
||||
|
||||
import dev.sheldan.abstracto.core.service.JSONValidationService;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.everit.json.schema.ValidationException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class JSONValidationResult {
|
||||
private JSONValidationService.Result result;
|
||||
private List<ValidationException> exceptions;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ import javax.persistence.*;
|
||||
import java.io.Serializable;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Entity
|
||||
@Table(name="channel")
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
public class AChannel implements SnowFlake, Serializable {
|
||||
|
||||
@Id
|
||||
@@ -50,5 +50,16 @@ public class AChannel implements SnowFlake, Serializable {
|
||||
@Transient
|
||||
private boolean fake;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AChannel channel = (AChannel) o;
|
||||
return id.equals(channel.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ public interface ChannelGroupService {
|
||||
void enableChannelGroup(String channelGroupName, Long serverId);
|
||||
boolean isChannelInEnabledChannelGroupOfType(String channelGroupType, Long channelId);
|
||||
boolean doesGroupExist(String groupName, Long serverId);
|
||||
boolean isChannelInGroup(AChannel channel, AChannelGroup aChannelGroup);
|
||||
List<AChannelGroup> getChannelGroupsOfChannelWithType(AChannel channel, String groupTypeKey);
|
||||
List<ChannelGroupModel> convertAChannelGroupToChannelGroupChannel(List<AChannelGroup> channelGroups);
|
||||
}
|
||||
|
||||
@@ -65,4 +65,5 @@ public interface ChannelService {
|
||||
TextChannel getTextChannelFromServer(Long serverId, Long textChannelId);
|
||||
CompletableFuture<Void> setSlowModeInChannel(TextChannel textChannel, Integer seconds);
|
||||
List<CompletableFuture<Message>> sendFileToChannel(String fileContent, String fileNameTemplate, String messageTemplate, Object model, TextChannel channel);
|
||||
List<CompletableFuture<Message>> sendFileToChannel(String fileContent, String fileName, TextChannel channel);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.sheldan.abstracto.core.service;
|
||||
|
||||
|
||||
import dev.sheldan.abstracto.core.models.JSONValidationResult;
|
||||
import org.everit.json.schema.ValidationException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
public interface JSONValidationService {
|
||||
JSONValidationResult validateJSONSchema(InputStream schema, File jsonFile) throws IOException;
|
||||
JSONValidationResult validateJSONSchema(InputStream schema, InputStream jsonFile);
|
||||
JSONValidationResult validateJSONSchema(JSONObject schema, Object json) throws IOException;
|
||||
JSONValidationResult validateJSONSchema(String schema, String json);
|
||||
JSONValidationResult validateJSONSchema(File schema, File jsonFile) throws IOException;
|
||||
List<ValidationException> getDetailedException(List<ValidationException> exceptions);
|
||||
|
||||
enum Result {
|
||||
SUCCESSFUL, ERRONEOUS
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package dev.sheldan.abstracto.core.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
|
||||
import net.dv8tion.jda.api.entities.SelfUser;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface UserService {
|
||||
CompletableFuture<User> retrieveUserForId(Long id);
|
||||
CompletableFutureList<User> retrieveUsers(List<Long> ids);
|
||||
SelfUser getSelfUser();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ public class MessageToSend {
|
||||
/**
|
||||
* The string content to be used in the first message.
|
||||
*/
|
||||
private List<String> messages;
|
||||
@Builder.Default
|
||||
private List<String> messages = new ArrayList<>();
|
||||
/**
|
||||
* The file handle to send attached to the message.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user