added undo logic to mod mail logging

added some more logging when closing the mod mail thread
This commit is contained in:
Sheldan
2020-05-09 01:10:46 +02:00
parent 379db1ff73
commit 0e7add826b
4 changed files with 99 additions and 26 deletions

View File

@@ -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));
}
});
}

View File

@@ -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();
}
}

View File

@@ -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;
}