[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:
Sheldan
2021-02-13 14:48:56 +01:00
parent 047c574319
commit 34b9bca7ac
114 changed files with 88 additions and 460 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -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())) {

View File

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

View File

@@ -3,7 +3,6 @@ package dev.sheldan.abstracto.core.command.models.database;
import dev.sheldan.abstracto.core.models.database.AChannelGroupCommand;
import dev.sheldan.abstracto.core.models.database.AFeature;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -17,9 +16,7 @@ import java.util.List;
@AllArgsConstructor
@Getter
@Setter
@Cacheable
@EqualsAndHashCode
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ACommand implements Serializable {
@Id
@Column(name = "id")

View File

@@ -3,7 +3,6 @@ package dev.sheldan.abstracto.core.command.models.database;
import dev.sheldan.abstracto.core.models.database.ARole;
import dev.sheldan.abstracto.core.models.database.AServer;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -17,8 +16,6 @@ import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ACommandInAServer implements Serializable {
@Id
@@ -40,7 +37,6 @@ public class ACommandInAServer implements Serializable {
joinColumns = @JoinColumn(name = "command_in_server_id", referencedColumnName = "command_in_server_id"),
inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
@Getter
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<ARole> allowedRoles;
@ManyToMany
@@ -49,7 +45,6 @@ public class ACommandInAServer implements Serializable {
joinColumns = @JoinColumn(name = "command_in_server_id", referencedColumnName = "command_in_server_id"),
inverseJoinColumns = @JoinColumn(name = "role_id", referencedColumnName = "id"))
@Getter
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<ARole> immuneRoles;
@Getter

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.command.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -16,8 +15,6 @@ import java.util.List;
@AllArgsConstructor
@Getter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AModule implements Serializable {
@Id
@@ -32,7 +29,6 @@ public class AModule implements Serializable {
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
orphanRemoval = true, mappedBy = "module")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<ACommand> commands = new ArrayList<>();
@Column(name = "created")

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.models.SnowFlake;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AChannel implements SnowFlake, Serializable {
@Id
@@ -26,7 +23,6 @@ public class AChannel implements SnowFlake, Serializable {
@Getter
@ManyToMany(mappedBy = "channels")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AChannelGroup> groups;
@ManyToOne(fetch = FetchType.LAZY)

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -16,8 +15,6 @@ import java.util.List;
@Getter
@Setter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AChannelGroup implements Serializable {
@Id
@@ -50,7 +47,6 @@ public class AChannelGroup implements Serializable {
name = "channel_in_group",
joinColumns = @JoinColumn(name = "group_id"),
inverseJoinColumns = @JoinColumn(name = "channel_id"))
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AChannel> channels;

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.command.models.database.ACommand;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.time.Instant;
@AllArgsConstructor
@Getter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AChannelGroupCommand implements Serializable {
@Id

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.time.Instant;
@Getter
@Setter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AConfig implements Serializable {
@Id

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.models.Fakeable;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.time.Instant;
@AllArgsConstructor
@Getter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AEmote implements Serializable, Fakeable {
@javax.persistence.Id

View File

@@ -3,7 +3,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.command.models.database.ACommand;
import dev.sheldan.abstracto.core.models.SnowFlake;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -16,8 +15,6 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AFeature implements SnowFlake, Serializable {
@Id
@@ -34,7 +31,6 @@ public class AFeature implements SnowFlake, Serializable {
@Getter
@Setter
@OneToMany(fetch = FetchType.LAZY, mappedBy = "feature")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<ACommand> commands;
@Column(name = "created")

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -16,8 +15,6 @@ import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AFeatureFlag implements Serializable {
@Id
@@ -34,7 +31,6 @@ public class AFeatureFlag implements Serializable {
private AFeature feature;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "featureFlag")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AFeatureMode> modes;
@Column(name = "enabled")

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.time.Instant;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AFeatureMode implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.models.SnowFlake;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -14,8 +13,6 @@ import java.time.Instant;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ARole implements SnowFlake, Serializable {
@Id

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.models.SnowFlake;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -17,8 +16,6 @@ import java.util.List;
@AllArgsConstructor
@Getter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AServer implements SnowFlake, Serializable {
@Id
@@ -44,7 +41,6 @@ public class AServer implements SnowFlake, Serializable {
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
mappedBy = "server")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<ARole> roles = new ArrayList<>();
@OneToMany(
@@ -53,7 +49,6 @@ public class AServer implements SnowFlake, Serializable {
orphanRemoval = true,
mappedBy = "server")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AChannel> channels = new ArrayList<>();
@OneToMany(
@@ -62,7 +57,6 @@ public class AServer implements SnowFlake, Serializable {
orphanRemoval = true,
mappedBy = "server")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AChannelGroup> channelGroups = new ArrayList<>();
@OneToMany(
@@ -71,7 +65,6 @@ public class AServer implements SnowFlake, Serializable {
orphanRemoval = true,
mappedBy = "serverReference")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AUserInAServer> users = new ArrayList<>();
@OneToMany(
@@ -80,7 +73,6 @@ public class AServer implements SnowFlake, Serializable {
orphanRemoval = true,
mappedBy = "serverRef")
@Builder.Default
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AEmote> emotes = new ArrayList<>();

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.util.List;
@NoArgsConstructor
@Getter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AUser implements Serializable {
@Id
@@ -27,7 +24,6 @@ public class AUser implements Serializable {
fetch = FetchType.LAZY,
cascade = {CascadeType.PERSIST, CascadeType.MERGE},
mappedBy = "serverReference")
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
private List<AUserInAServer> servers;
@Column(name = "created")

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.time.Instant;
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AUserInAServer implements Serializable {
@Id

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -13,11 +12,9 @@ import java.time.Instant;
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Cacheable
@Getter
@Setter
@ToString
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class AllowedMention implements Serializable {
@Id

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.time.Instant;
@@ -14,8 +13,6 @@ import java.time.Instant;
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ChannelGroupType {
@Id

View File

@@ -2,7 +2,6 @@ package dev.sheldan.abstracto.core.models.database;
import dev.sheldan.abstracto.core.models.CounterId;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -15,8 +14,6 @@ import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Counter implements Serializable {
@EmbeddedId

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -14,8 +13,6 @@ import java.time.Instant;
@AllArgsConstructor
@Getter
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class DefaultEmote implements Serializable {
@javax.persistence.Id

View File

@@ -1,7 +1,6 @@
package dev.sheldan.abstracto.core.models.database;
import lombok.*;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
@@ -13,8 +12,6 @@ import java.time.Instant;
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class PostTarget implements Serializable {
@Id

View File

@@ -33,5 +33,6 @@ public interface MessageService {
CompletableFuture<Message> loadMessage(Long serverId, Long channelId, Long messageId);
MessageAction editMessage(Message message, MessageEmbed messageEmbed);
MessageAction editMessage(Message message, String text, MessageEmbed messageEmbed);
AuditableRestAction<Void> deleteMessage(Message message);
AuditableRestAction<Void> deleteMessageWithAction(Message message);
CompletableFuture<Void> deleteMessage(Message message);
}

View File

@@ -1,5 +1,7 @@
package dev.sheldan.abstracto.core.service;
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;
@@ -26,6 +28,8 @@ public interface ReactionService {
CompletableFuture<Void> removeReaction(Message message, String key, User user);
CompletableFuture<Void> removeReaction(Message message, Emote emoteById);
CompletableFuture<Void> removeReaction(Message message, Emote emoteById, User user);
CompletableFuture<Void> removeReaction(Message message, CachedEmote cachedEmote, User user);
CompletableFuture<Void> removeReaction(CachedMessage message, CachedEmote cachedEmote, ServerUser user);
CompletableFuture<Void> removeReactionFromMessageWithFuture(AEmote emote, Message message);
CompletableFuture<Void> clearReactionFromMessageWithFuture(AEmote emote, Message message);
CompletableFuture<Void> clearReaction(Message message, String key);