mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-04-16 12:28:03 +00:00
[AB-209] adding cleanup job for old embedded messages, this job deletes the entries from the database and removes reactions
reducing thread count for listener executor and scheduling fixing channel deletion listener not being part of a transaction
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package dev.sheldan.abstracto.core.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.ServerChannelMessage;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
@@ -11,6 +12,7 @@ import net.dv8tion.jda.api.entities.User;
|
||||
import net.dv8tion.jda.api.requests.restaction.AuditableRestAction;
|
||||
import net.dv8tion.jda.api.requests.restaction.MessageAction;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public interface MessageService {
|
||||
@@ -22,6 +24,7 @@ public interface MessageService {
|
||||
void updateStatusMessage(MessageChannel channel, Long messageId, MessageToSend messageToSend);
|
||||
CompletableFuture<Message> sendMessageToUser(AUserInAServer userInAServer, String text);
|
||||
CompletableFuture<Message> sendSimpleTemplateToUser(Long userId, String templateKey);
|
||||
List<CompletableFuture<Message>> retrieveMessages(List<ServerChannelMessage> messages);
|
||||
CompletableFuture<Message> sendTemplateToUser(User user, String template, Object model);
|
||||
CompletableFuture<Void> sendEmbedToUser(User user, String template, Object model);
|
||||
CompletableFuture<Message> sendEmbedToUserWithMessage(User user, String template, Object model);
|
||||
|
||||
@@ -5,6 +5,7 @@ import dev.sheldan.abstracto.core.models.cache.CachedEmote;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
|
||||
import dev.sheldan.abstracto.core.models.cache.CachedReaction;
|
||||
import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.utils.CompletableFutureList;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -42,6 +43,7 @@ public interface ReactionService {
|
||||
CompletableFuture<Void> clearReactionFromMessageWithFuture(Integer emoteId, Message message);
|
||||
CompletableFuture<Void> removeReactionFromMessageWithFuture(AEmote emote, Long serverId, Long channelId, Long messageId);
|
||||
CompletableFuture<Void> removeReactionOfUserFromMessageWithFuture(AEmote emote, Long serverId, Long channelId, Long messageId, Long userId);
|
||||
CompletableFuture<Void> removeReactionOfUserFromMessageWithFuture(AEmote emote, Long serverId, Long channelId, Long messageId);
|
||||
CompletableFuture<Void> removeReactionOfUserFromMessageWithFuture(AEmote emote, Long serverId, Long channelId, Long messageId, Member member);
|
||||
CompletableFuture<Void> removeReactionOfUserFromMessageWithFuture(AEmote emote, Message message, Member member);
|
||||
CompletableFuture<Void> removeReactionOfUserFromMessageWithFuture(Integer emoteId, Message message, Member member);
|
||||
@@ -49,4 +51,10 @@ public interface ReactionService {
|
||||
CompletableFuture<Void> removeReactionOfUserFromMessageWithFuture(Integer emoteId, Message message, Long userId);
|
||||
CompletableFuture<Void> clearReactionFromMessageWithFuture(AEmote emote, Long serverId, Long channelId, Long messageId);
|
||||
List<CompletableFuture<Void>> addReactionsToMessageWithFuture(List<String> emoteKeys, Long serverId, Message message);
|
||||
List<CompletableFuture<Void>> removeReactionFromMessagesWithFuture(List<Message> messages, Integer emoteId);
|
||||
List<CompletableFuture<Void>> removeReactionFromMessagesWithFuture(List<Message> messages, AEmote emote);
|
||||
CompletableFutureList<Void> removeReactionFromMessagesWithFutureWithFutureList(List<Message> messages, Integer emoteId);
|
||||
CompletableFutureList<Void> removeReactionFromMessagesWithFutureWithFutureList(List<Message> messages, String emoteKey);
|
||||
List<CompletableFuture<Void>> removeReactionFromMessagesWithFuture(List<Message> messages, String emoteKey);
|
||||
CompletableFutureList<Void> removeReactionFromMessagesWithFutureWithFutureList(List<Message> messages, AEmote emote);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,11 @@ public class CompletableFutureList<T> {
|
||||
if(!future.isCompletedExceptionally()) {
|
||||
result.add(future.join());
|
||||
} else {
|
||||
log.warn("Future completed with exception {}.", future.join());
|
||||
try {
|
||||
future.join();
|
||||
} catch (Exception exception) {
|
||||
log.warn("Future completed with exception.", exception);
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user