mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-19 12:11:39 +00:00
added concept of undo actions
used undo actions to delete the mod mail thread channel, if it already reached a certain state when initially setting up the mod mail thread
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package dev.sheldan.abstracto.core.exception;
|
||||
|
||||
public class UndoActionException extends AbstractoRunTimeException {
|
||||
public UndoActionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package dev.sheldan.abstracto.core.models;
|
||||
|
||||
public enum UndoAction {
|
||||
DELETE_CHANNEL, DELETE_MESSAGE
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package dev.sheldan.abstracto.core.models;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Builder
|
||||
@Setter
|
||||
public class UndoActionInstance {
|
||||
private List<Long> ids;
|
||||
private UndoAction action;
|
||||
|
||||
public static UndoActionInstance getChannelDeleteAction(Long channelId, Long serverId) {
|
||||
return UndoActionInstance
|
||||
.builder()
|
||||
.action(UndoAction.DELETE_CHANNEL)
|
||||
.ids(Arrays.asList(serverId, channelId))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ public interface ChannelService {
|
||||
void editMessageInAChannel(MessageToSend messageToSend, AChannel channel, Long messageId);
|
||||
void editMessageInAChannel(MessageToSend messageToSend, MessageChannel channel, Long messageId);
|
||||
CompletableFuture<Void> deleteTextChannel(AChannel channel);
|
||||
CompletableFuture<Void> deleteTextChannel(Long serverId, Long channelId);
|
||||
List<CompletableFuture<Message>> sendTemplateInChannel(String templateKey, Object model, MessageChannel channel);
|
||||
|
||||
CompletableFuture<TextChannel> createTextChannel(String name, AServer server, Long categoryId);
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package dev.sheldan.abstracto.core.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.UndoActionInstance;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface UndoActionService {
|
||||
void performActions(List<UndoActionInstance> actionsToPerform);
|
||||
}
|
||||
Reference in New Issue
Block a user