[AB-154] split up private and guild message received handler, split handlers into async and sync handlers

adapting the tests and improving tests to reduce usage of MockUtils
adding some util methods to message bean
extending cache for cached messages
enabling to build cached messages from messages in DM channels (they are not part of the message cache)
splitting multiple listeners to different beans, for better overview (emote updated)
adding convenience service for reactions specifically
split cached reaction and cached reactions, singular only contains one user, while the later contains all users
fixing liquibase configuration for assigned role user
fixing assignable role not having a transaction
moved caching update a bit earlier in various methods
fixing bug that a manual unmute caused duplicate unmute notification
fixing short scheduled unmute not checking the new mute state
limiting parameters for roll
This commit is contained in:
Sheldan
2020-12-20 19:21:24 +01:00
parent 69aa82e26e
commit fb3ed69650
200 changed files with 4253 additions and 1813 deletions

View File

@@ -1,5 +1,6 @@
package dev.sheldan.abstracto.statistic.emotes.service;
import dev.sheldan.abstracto.core.models.cache.CachedEmote;
import dev.sheldan.abstracto.statistic.emotes.model.PersistingEmote;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.Guild;
@@ -25,17 +26,17 @@ public interface TrackedEmoteRuntimeService {
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param external Whether or not the emote is external
*/
void addEmoteForServer(Emote emote, Guild guild, boolean external);
void addEmoteForServer(CachedEmote emote, Guild guild, boolean external);
/**
* Adds the given {@link Emote} used in the {@link Guild} to the runtime storage.
* The necessary lock will be acquired by this method.
* @param emote The {@link Emote} to add to the runtime storage
* @param emote The {@link CachedEmote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param count The amount of usages which should be added
* @param external Whether or not the emote is external
*/
void addEmoteForServer(Emote emote, Guild guild, Long count, boolean external);
void addEmoteForServer(CachedEmote emote, Guild guild, Long count, boolean external);
/**
* Calculates the key used for the Map containing the emote statistics.
@@ -46,21 +47,21 @@ public interface TrackedEmoteRuntimeService {
/**
* Creates a {@link PersistingEmote} from the given parameters.
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param emote The {@link Emote} to create a {@link PersistingEmote} from
* @param emote The {@link CachedEmote} to create a {@link PersistingEmote} from
* @param external Whether or not the {@link Emote} is external
* @return A created {@link PersistingEmote} instance from the {@link Emote}
*/
PersistingEmote createFromEmote(Guild guild, Emote emote, boolean external);
PersistingEmote createFromEmote(Guild guild, CachedEmote emote, boolean external);
/**
* Creates a {@link PersistingEmote} from the given parameters.
* @param guild The {@link Guild} in which the {@link Emote} is used
* @param emote The {@link Emote} to create a {@link PersistingEmote} from
* @param emote The {@link CachedEmote} to create a {@link PersistingEmote} from
* @param count The amount of usages the {@link Emote} has been used
* @param external Whether or not the {@link Emote} is external
* @return A created {@link PersistingEmote} instance from the {@link Emote}
*/
PersistingEmote createFromEmote(Guild guild, Emote emote, Long count, boolean external);
PersistingEmote createFromEmote(Guild guild, CachedEmote emote, Long count, boolean external);
/**
* Acquires the lock which should be used when accessing the runtime storage

View File

@@ -1,5 +1,6 @@
package dev.sheldan.abstracto.statistic.emotes.service;
import dev.sheldan.abstracto.core.models.cache.CachedEmote;
import dev.sheldan.abstracto.statistic.emotes.model.PersistingEmote;
import dev.sheldan.abstracto.statistic.emotes.model.TrackedEmoteOverview;
import dev.sheldan.abstracto.statistic.emotes.model.TrackedEmoteSynchronizationResult;
@@ -20,15 +21,15 @@ public interface TrackedEmoteService {
* @param emotes The list of {@link Emote}s to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote}s were used and where the usages should be added
*/
void addEmoteToRuntimeStorage(List<Emote> emotes, Guild guild);
void addEmoteToRuntimeStorage(List<CachedEmote> emotes, Guild guild);
/**
* Adds the given {@link Emote} with the given amount to the runtime storage for the given {@link Guild}
* @param emote The {@link Emote} to add to the runtime storage
* @param emote The {@link CachedEmote} to add to the runtime storage
* @param guild The {@link Guild} in which the {@link Emote} was used and in which the usage should be added
* @param count The amount of times which the {@link Emote} has been used and should be reflected in the runtime storage
*/
void addEmoteToRuntimeStorage(Emote emote, Guild guild, Long count);
void addEmoteToRuntimeStorage(CachedEmote emote, Guild guild, Long count);
/**
* Takes the given map of server_ids with the list of {@link PersistingEmote} and stores the objects in the database

View File

@@ -1,6 +1,7 @@
package dev.sheldan.abstracto.statistic.emotes.service.management;
import dev.sheldan.abstracto.core.models.ServerSpecificId;
import dev.sheldan.abstracto.core.models.cache.CachedEmote;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.statistic.emotes.exception.TrackedEmoteNotFoundException;
import dev.sheldan.abstracto.statistic.emotes.model.PersistingEmote;
@@ -33,6 +34,13 @@ public interface TrackedEmoteManagementService {
*/
TrackedEmote createTrackedEmote(Emote emote, Guild guild);
/**
* Creates and persists a {@link TrackedEmote} for which tracking is enabled based on the given {@link Emote} and {@link Guild}
* @param emote The {@link CachedEmote} to be used to create a {@link TrackedEmote}
* @return The created {@link TrackedEmote} instance in the database
*/
TrackedEmote createTrackedEmote(CachedEmote emote);
/**
* Creates and persist a {@link TrackedEmote} for which tracking is enabled based on the given {@link Emote} and {@link Guild}
* @param emote The {@link Emote} to be used to create a {@link TrackedEmote}