mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-31 23:32:26 +00:00
[AB-192] removing second level cache
changing assignable role place module name fixing starboard retrieving the starstats incorrectly fixing removing user assigned roles when removing a role from assignable role place fixing not being able to remove external emote for assignable role place
This commit is contained in:
@@ -4,17 +4,13 @@ import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroupCommand;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ChannelGroupCommandRepository extends JpaRepository<AChannelGroupCommand, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AChannelGroupCommand> findByCommandAndGroup(ACommand command, AChannelGroup group);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AChannelGroupCommand> findByCommand(ACommand command);
|
||||
}
|
||||
|
||||
@@ -4,17 +4,13 @@ import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommandInAServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
|
||||
@Repository
|
||||
public interface CommandInServerRepository extends JpaRepository<ACommandInAServer, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
ACommandInAServer findByServerReferenceAndCommandReference(AServer server, ACommand command);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
ACommandInAServer findByServerReference_IdAndCommandReference(Long serverId, ACommand command);
|
||||
}
|
||||
|
||||
@@ -2,18 +2,14 @@ package dev.sheldan.abstracto.core.command.repository;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.database.ACommand;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface CommandRepository extends JpaRepository<ACommand, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<ACommand> findByNameIgnoreCase(String name);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByNameIgnoreCase(String name);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,9 @@ package dev.sheldan.abstracto.core.command.repository;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.models.database.AModule;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
|
||||
public interface ModuleRepository extends JpaRepository<AModule, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
AModule findByName(String name);
|
||||
}
|
||||
|
||||
@@ -4,29 +4,22 @@ import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannelGroup;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface ChannelGroupRepository extends JpaRepository<AChannelGroup, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AChannelGroup> findByGroupNameAndServer(String name, AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AChannelGroup> findByGroupNameAndServerAndChannelGroupType_GroupTypeKey(String name, AServer server, String groupTyeKey);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AChannelGroup> findByServerAndChannelGroupType_GroupTypeKey(AServer server, String groupTyeKey);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AChannelGroup> findByServer(AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByGroupNameAndServer(String name, AServer server);
|
||||
|
||||
List<AChannelGroup> findAllByChannels(AChannel channel);
|
||||
|
||||
@@ -3,11 +3,9 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.AChannel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
@@ -15,10 +13,8 @@ public interface ChannelRepository extends JpaRepository<AChannel, Long> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AChannel> findById(@NonNull Long aLong);
|
||||
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsById(@NonNull Long aLong);
|
||||
}
|
||||
|
||||
@@ -3,20 +3,15 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.AConfig;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
|
||||
@Repository
|
||||
public interface ConfigRepository extends JpaRepository<AConfig, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
AConfig findAConfigByServerIdAndName(Long serverId, String name);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsAConfigByServerIdAndName(Long serverId, String name);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsAConfigByServerAndName(AServer server, String name);
|
||||
}
|
||||
|
||||
@@ -3,19 +3,15 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.DefaultEmote;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface DefaultEmoteRepository extends JpaRepository<DefaultEmote, Long> {
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
DefaultEmote getByEmoteKey(String emoteKey);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<DefaultEmote> findAll();
|
||||
}
|
||||
|
||||
@@ -4,33 +4,25 @@ import dev.sheldan.abstracto.core.models.database.AEmote;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface EmoteRepository extends JpaRepository<AEmote, Integer> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
AEmote findAEmoteByNameAndServerRef(String name, AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByNameAndServerRef(String name, AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AEmote> findByEmoteId(Long emoteId);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByEmoteId(Long emoteId);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByEmoteIdAndServerRef(String emoteId, AServer server);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AEmote> findById(@NonNull Integer aLong);
|
||||
}
|
||||
|
||||
@@ -4,20 +4,15 @@ import dev.sheldan.abstracto.core.models.database.AFeature;
|
||||
import dev.sheldan.abstracto.core.models.database.AFeatureFlag;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface FeatureFlagRepository extends JpaRepository<AFeatureFlag, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AFeatureFlag> findByServerAndFeature(AServer server, AFeature key);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByServerAndFeature(AServer server, AFeature key);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AFeatureFlag> findAllByServer(AServer server);
|
||||
}
|
||||
|
||||
@@ -4,23 +4,18 @@ import dev.sheldan.abstracto.core.models.database.AFeature;
|
||||
import dev.sheldan.abstracto.core.models.database.AFeatureMode;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface FeatureModeRepository extends JpaRepository<AFeatureMode, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AFeatureMode> findByServerAndFeatureFlag_FeatureAndFeatureMode(AServer server, AFeature feature, String mode);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AFeatureMode> findByServer(AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AFeatureMode> findByServerAndFeatureFlag_Feature(AServer server, AFeature feature);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,14 +2,11 @@ package dev.sheldan.abstracto.core.repository;
|
||||
|
||||
import dev.sheldan.abstracto.core.models.database.AFeature;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
|
||||
@Repository
|
||||
public interface FeatureRepository extends JpaRepository<AFeature, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
AFeature findByKey(String key);
|
||||
}
|
||||
|
||||
@@ -3,22 +3,17 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.models.database.PostTarget;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface PostTargetRepository extends JpaRepository<PostTarget, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
PostTarget findPostTargetByNameAndServerReference(String name, AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByNameAndServerReference(String name, AServer server);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<PostTarget> findByServerReference(AServer server);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,17 +3,14 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.ARole;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface RoleRepository extends JpaRepository<ARole, Long> {
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<ARole> findById(@NonNull Long aLong);
|
||||
}
|
||||
|
||||
@@ -3,11 +3,9 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -16,15 +14,12 @@ public interface ServerRepository extends JpaRepository<AServer, Long> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AServer> findById(@NonNull Long aLong);
|
||||
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsById(@NonNull Long aLong);
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AServer> findAll();
|
||||
}
|
||||
|
||||
@@ -4,28 +4,21 @@ import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.models.database.AUser;
|
||||
import dev.sheldan.abstracto.core.models.database.AUserInAServer;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserInServerRepository extends JpaRepository<AUserInAServer, Long> {
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AUserInAServer> findByServerReferenceAndUserReference(AServer serverId, AUser userId);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AUserInAServer> findByServerReference_IdAndUserReference_Id(Long serverId, Long userId);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByServerReferenceAndUserReference(AServer server, AUser user);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsByServerReference_IdAndUserReference_Id(Long serverId, Long userId);
|
||||
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
List<AUserInAServer> findByUserReference(AUser user);
|
||||
}
|
||||
@@ -3,21 +3,17 @@ package dev.sheldan.abstracto.core.repository;
|
||||
import dev.sheldan.abstracto.core.models.database.AUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.QueryHints;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.QueryHint;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<AUser, Long> {
|
||||
@NotNull
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
Optional<AUser> findById(@NonNull Long aLong);
|
||||
|
||||
@Override
|
||||
@QueryHints(@QueryHint(name = org.hibernate.annotations.QueryHints.CACHEABLE, value = "true"))
|
||||
boolean existsById(@NonNull Long aLong);
|
||||
}
|
||||
|
||||
@@ -1,36 +1,20 @@
|
||||
package dev.sheldan.abstracto.core.service;
|
||||
|
||||
import dev.sheldan.abstracto.core.exception.AbstractoRunTimeException;
|
||||
import dev.sheldan.abstracto.templating.service.TemplateService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CacheServiceBean {
|
||||
|
||||
private SessionFactory sessionFactory;
|
||||
|
||||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
@Autowired
|
||||
public CacheServiceBean(EntityManagerFactory factory) {
|
||||
SessionFactory unWrapped = factory.unwrap(SessionFactory.class);
|
||||
if(unWrapped == null){
|
||||
throw new AbstractoRunTimeException("Factory is not a hibernate factory.");
|
||||
}
|
||||
this.sessionFactory = unWrapped;
|
||||
}
|
||||
|
||||
public void clearCaches() {
|
||||
log.info("Clearing all caches.");
|
||||
sessionFactory.getCache().evictAllRegions();
|
||||
templateService.clearCache();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,11 +179,16 @@ public class MessageServiceBean implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AuditableRestAction<Void> deleteMessage(Message message) {
|
||||
public AuditableRestAction<Void> deleteMessageWithAction(Message message) {
|
||||
metricService.incrementCounter(MESSAGE_DELETE_METRIC);
|
||||
return message.delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> deleteMessage(Message message) {
|
||||
return deleteMessageWithAction(message).submit();
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void postConstruct() {
|
||||
metricService.registerCounter(MESSAGE_SEND_METRIC, "Messages send to discord");
|
||||
|
||||
@@ -5,10 +5,13 @@ import dev.sheldan.abstracto.core.exception.EmoteNotInServerException;
|
||||
import dev.sheldan.abstracto.core.metrics.service.CounterMetric;
|
||||
import dev.sheldan.abstracto.core.metrics.service.MetricService;
|
||||
import dev.sheldan.abstracto.core.metrics.service.MetricTag;
|
||||
import dev.sheldan.abstracto.core.models.ServerUser;
|
||||
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.service.management.EmoteManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.dv8tion.jda.api.entities.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -211,6 +214,22 @@ public class ReactionServiceBean implements ReactionService {
|
||||
return message.removeReaction(emoteById, user).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReaction(Message message, CachedEmote cachedEmote, User user) {
|
||||
metricService.incrementCounter(REACTION_REMOVED_METRIC);
|
||||
String customEmoteAsUnicode = cachedEmote.getEmoteName() + ":" + cachedEmote.getEmoteId();
|
||||
return ((TextChannel) message.getChannel()).removeReactionById(message.getId(), customEmoteAsUnicode, user).submit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> removeReaction(CachedMessage message, CachedEmote cachedEmote, ServerUser user) {
|
||||
CompletableFuture<Message> messageFuture = messageService.loadMessageFromCachedMessage(message);
|
||||
CompletableFuture<Member> memberFuture = memberService.retrieveMemberInServer(user);
|
||||
return FutureUtils.toSingleFuture(Arrays.asList(messageFuture, memberFuture)).thenCompose(unused -> {
|
||||
return removeReaction(messageFuture.join(), cachedEmote, memberFuture.join().getUser());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> clearReactionFromMessageWithFuture(AEmote emote, Message message) {
|
||||
if(Boolean.TRUE.equals(emote.getCustom())) {
|
||||
|
||||
@@ -4,8 +4,8 @@ spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
|
||||
spring.jpa.properties.hibernate.format_sql = false
|
||||
|
||||
spring.jpa.properties.hibernate.generate_statistics = false
|
||||
spring.jpa.properties.hibernate.cache.use_second_level_cache=true
|
||||
spring.jpa.properties.hibernate.cache.use_query_cache=true
|
||||
spring.jpa.properties.hibernate.cache.use_second_level_cache=false
|
||||
spring.jpa.properties.hibernate.cache.use_query_cache=false
|
||||
spring.jpa.properties.hibernate.cache.region.factory_class=org.hibernate.cache.jcache.JCacheRegionFactory
|
||||
spring.jpa.properties.javax.persistence.sharedCache.mode=ENABLE_SELECTIVE
|
||||
spring.jpa.properties.hibernate.javax.cache.missing_cache_strategy = create
|
||||
|
||||
Reference in New Issue
Block a user