mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-01-19 14:32:52 +00:00
[AB-243] when loading messages we ignore embed links part of a channel/guild which are not available anymore
This commit is contained in:
@@ -126,14 +126,20 @@ public class MessageServiceBean implements MessageService {
|
||||
.collect(Collectors.groupingBy(ServerChannelMessage::getServerId));
|
||||
serverMessages.forEach((serverId, channelMessagesNonGrouped) -> {
|
||||
Guild guild = guildService.getGuildById(serverId);
|
||||
Map<Long, List<ServerChannelMessage>> channelMessages = channelMessagesNonGrouped
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(ServerChannelMessage::getChannelId));
|
||||
channelMessages.forEach((channelId, serverChannelMessages) -> {
|
||||
MessageChannel channel = guild.getTextChannelById(channelId);
|
||||
serverChannelMessages.forEach(serverChannelMessage ->
|
||||
messageFutures.add(channelService.retrieveMessageInChannel(channel, serverChannelMessage.getMessageId())));
|
||||
});
|
||||
// in case the gild is not available anymore, this would cause the job to fail
|
||||
if(guild != null) {
|
||||
Map<Long, List<ServerChannelMessage>> channelMessages = channelMessagesNonGrouped
|
||||
.stream()
|
||||
.collect(Collectors.groupingBy(ServerChannelMessage::getChannelId));
|
||||
channelMessages.forEach((channelId, serverChannelMessages) -> {
|
||||
MessageChannel channel = guild.getTextChannelById(channelId);
|
||||
// in case the channel was deleted, this would cause the job to fail
|
||||
if(channel != null) {
|
||||
serverChannelMessages.forEach(serverChannelMessage ->
|
||||
messageFutures.add(channelService.retrieveMessageInChannel(channel, serverChannelMessage.getMessageId())));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return messageFutures;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user