fixed link embedding not properly working with sessions

This commit is contained in:
Sheldan
2020-05-12 08:59:08 +02:00
parent 5639ca20b5
commit 1634f5e9cc
4 changed files with 29 additions and 16 deletions

View File

@@ -14,8 +14,8 @@ import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.awt.*;
import java.time.Instant;
@@ -44,6 +44,11 @@ public class MessageCacheBean implements MessageCache {
// needs to be lazy, because of circular dependency
private MessageCache self;
@Autowired
@Lazy
// needs to be lazy, because of circular dependency
private MessageCacheBean concreteSelf;
@Override
@CachePut(key = "#message.id")
public CompletableFuture<CachedMessage> putMessageInCache(Message message) {
@@ -155,9 +160,7 @@ public class MessageCacheBean implements MessageCache {
List<Long> ausers = new ArrayList<>();
users.forEachAsync(user -> {
if(reaction.getGuild() != null) {
ausers.add(userInServerManagementService.loadUser(reaction.getGuild().getIdLong(), user.getIdLong()).getUserInServerId());
}
concreteSelf.loadUser(reaction, ausers, user);
return false;
}).thenAccept(o -> future.complete(builder.build()))
.exceptionally(throwable -> {
@@ -168,6 +171,13 @@ public class MessageCacheBean implements MessageCache {
builder.emote(emoteService.buildAEmoteFromReaction(reaction.getReactionEmote()));
}
@Transactional
public void loadUser(MessageReaction reaction, List<Long> ausers, User user) {
if(reaction.getGuild() != null) {
ausers.add(userInServerManagementService.loadUser(reaction.getGuild().getIdLong(), user.getIdLong()).getUserInServerId());
}
}
private CachedEmbed getCachedEmbedFromEmbed(MessageEmbed embed) {
CachedEmbed.CachedEmbedBuilder builder = CachedEmbed
.builder();