mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-07-04 04:07:43 +00:00
added undo logic to mod mail logging
added some more logging when closing the mod mail thread
This commit is contained in:
@@ -23,13 +23,21 @@ public class UndoActionServiceBean implements UndoActionService {
|
||||
public void performActions(List<UndoActionInstance> actionsToPerform) {
|
||||
actionsToPerform.forEach(undoActionInstance -> {
|
||||
UndoAction action = undoActionInstance.getAction();
|
||||
List<Long> ids = undoActionInstance.getIds();
|
||||
switch (action) {
|
||||
case DELETE_CHANNEL:
|
||||
if(undoActionInstance.getIds().size() != 2) {
|
||||
throw new UndoActionException("Not the correct amount of ides provided for the channel deletion undo action");
|
||||
if(ids.size() != 2) {
|
||||
log.error("Not the correct amount of ids provided for the channel deletion undo action.");
|
||||
break;
|
||||
}
|
||||
deleteChannel(undoActionInstance.getIds().get(0), undoActionInstance.getIds().get(1));
|
||||
deleteChannel(ids.get(0), ids.get(1));
|
||||
break;
|
||||
case DELETE_MESSAGE:
|
||||
if(ids.size() != 3) {
|
||||
log.error("Not the correct amount of ids provided for the message deletion undo action.");
|
||||
break;
|
||||
}
|
||||
botService.deleteMessage(ids.get(0), ids.get(1), ids.get(2));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -14,11 +14,19 @@ public class UndoActionInstance {
|
||||
private List<Long> ids;
|
||||
private UndoAction action;
|
||||
|
||||
public static UndoActionInstance getChannelDeleteAction(Long channelId, Long serverId) {
|
||||
public static UndoActionInstance getChannelDeleteAction(Long serverId, Long channelId) {
|
||||
return UndoActionInstance
|
||||
.builder()
|
||||
.action(UndoAction.DELETE_CHANNEL)
|
||||
.ids(Arrays.asList(serverId, channelId))
|
||||
.build();
|
||||
}
|
||||
|
||||
public static UndoActionInstance getMessageDeleteAction(Long serverId, Long channelId, Long messageId) {
|
||||
return UndoActionInstance
|
||||
.builder()
|
||||
.action(UndoAction.DELETE_MESSAGE)
|
||||
.ids(Arrays.asList(serverId, channelId, messageId))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package dev.sheldan.abstracto.core.utils;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
public class CompletableFutureList<T> {
|
||||
private CompletableFuture<Void> mainFuture;
|
||||
private List<CompletableFuture<T>> futures;
|
||||
}
|
||||
Reference in New Issue
Block a user