mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-27 14:23:56 +00:00
[AB-68] adding invite filter with commands to allow/disallow invites, remove stored filtered invite links and show filtered invite links
removing database entities from command context
This commit is contained in:
@@ -7,7 +7,9 @@ import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
import dev.sheldan.abstracto.statistic.emotes.config.EmoteTrackingModule;
|
||||
@@ -38,6 +40,9 @@ public class DeletedEmoteStats extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
public static final String EMOTE_STATS_STATIC_DELETED_RESPONSE = "deletedEmoteStats_static_response";
|
||||
public static final String EMOTE_STATS_ANIMATED_DELETED_RESPONSE = "deletedEmoteStats_animated_response";
|
||||
|
||||
@@ -51,7 +56,8 @@ public class DeletedEmoteStats extends AbstractConditionableCommand {
|
||||
Duration duration = (Duration) parameters.get(0);
|
||||
statsSince = Instant.now().minus(duration);
|
||||
}
|
||||
EmoteStatsModel emoteStatsModel = usedEmoteService.getDeletedEmoteStatsForServerSince(commandContext.getUserInitiatedContext().getServer(), statsSince);
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
EmoteStatsModel emoteStatsModel = usedEmoteService.getDeletedEmoteStatsForServerSince(server, statsSince);
|
||||
List<CompletableFuture<Message>> messagePromises = new ArrayList<>();
|
||||
// only show the embed, if there are static emotes to show
|
||||
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
||||
|
||||
@@ -7,7 +7,9 @@ import dev.sheldan.abstracto.core.command.config.Parameter;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
import dev.sheldan.abstracto.statistic.emotes.config.EmoteTrackingModule;
|
||||
@@ -38,6 +40,9 @@ public class EmoteStats extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
public static final String EMOTE_STATS_STATIC_RESPONSE = "emoteStats_static_response";
|
||||
public static final String EMOTE_STATS_ANIMATED_RESPONSE = "emoteStats_animated_response";
|
||||
public static final String EMOTE_STATS_NO_STATS_AVAILABLE = "emoteStats_no_stats_available";
|
||||
@@ -52,7 +57,8 @@ public class EmoteStats extends AbstractConditionableCommand {
|
||||
Duration duration = (Duration) parameters.get(0);
|
||||
statsSince = Instant.now().minus(duration);
|
||||
}
|
||||
EmoteStatsModel emoteStatsModel = usedEmoteService.getActiveEmoteStatsForServerSince(commandContext.getUserInitiatedContext().getServer(), statsSince);
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
EmoteStatsModel emoteStatsModel = usedEmoteService.getActiveEmoteStatsForServerSince(server, statsSince);
|
||||
List<CompletableFuture<Message>> messagePromises = new ArrayList<>();
|
||||
// only show embed if static emote stats are available
|
||||
if(!emoteStatsModel.getStaticEmotes().isEmpty()) {
|
||||
|
||||
@@ -8,7 +8,9 @@ import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandResult;
|
||||
import dev.sheldan.abstracto.core.config.FeatureEnum;
|
||||
import dev.sheldan.abstracto.core.config.FeatureMode;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.utils.FutureUtils;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
import dev.sheldan.abstracto.statistic.emotes.config.EmoteTrackingMode;
|
||||
@@ -41,6 +43,9 @@ public class ExternalEmoteStats extends AbstractConditionableCommand {
|
||||
@Autowired
|
||||
private ChannelService channelService;
|
||||
|
||||
@Autowired
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
public static final String EMOTE_STATS_STATIC_EXTERNAL_RESPONSE = "externalEmoteStats_static_response";
|
||||
public static final String EMOTE_STATS_ANIMATED_EXTERNAL_RESPONSE = "externalEmoteStats_animated_response";
|
||||
|
||||
@@ -54,7 +59,8 @@ public class ExternalEmoteStats extends AbstractConditionableCommand {
|
||||
Duration duration = (Duration) parameters.get(0);
|
||||
statsSince = Instant.now().minus(duration);
|
||||
}
|
||||
EmoteStatsModel emoteStatsModel = usedEmoteService.getExternalEmoteStatsForServerSince(commandContext.getUserInitiatedContext().getServer(), statsSince);
|
||||
AServer server = serverManagementService.loadServer(commandContext.getGuild());
|
||||
EmoteStatsModel emoteStatsModel = usedEmoteService.getExternalEmoteStatsForServerSince(server, statsSince);
|
||||
List<CompletableFuture<Message>> messagePromises = new ArrayList<>();
|
||||
|
||||
// only show embed if static emote stats are available
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.sheldan.abstracto.statistic.emotes.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.test.command.CommandConfigValidator;
|
||||
import dev.sheldan.abstracto.core.test.command.CommandTestUtilities;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
@@ -38,6 +40,12 @@ public class DeletedEmoteStatsTest {
|
||||
@Mock
|
||||
private ChannelService channelService;
|
||||
|
||||
@Mock
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Mock
|
||||
private AServer server;
|
||||
|
||||
@Test
|
||||
public void testWithoutParameterStaticEmotes() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
@@ -45,7 +53,8 @@ public class DeletedEmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getStaticEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_STATIC_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -57,7 +66,8 @@ public class DeletedEmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getAnimatedEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_ANIMATED_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -67,7 +77,8 @@ public class DeletedEmoteStatsTest {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
EmoteStatsModel model = Mockito.mock(EmoteStatsModel.class);
|
||||
when(model.areStatsAvailable()).thenReturn(false);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -79,7 +90,8 @@ public class DeletedEmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getStaticEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(eq(noParameters.getUserInitiatedContext().getServer()), any(Instant.class))).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getDeletedEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_STATIC_DELETED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.sheldan.abstracto.statistic.emotes.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.test.command.CommandConfigValidator;
|
||||
import dev.sheldan.abstracto.core.test.command.CommandTestUtilities;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
@@ -38,6 +40,12 @@ public class EmoteStatsTest {
|
||||
@Mock
|
||||
private ChannelService channelService;
|
||||
|
||||
@Mock
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Mock
|
||||
private AServer server;
|
||||
|
||||
@Test
|
||||
public void testWithoutParameterStaticEmotes() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
@@ -45,7 +53,8 @@ public class EmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getStaticEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_STATIC_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -57,7 +66,8 @@ public class EmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getAnimatedEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_ANIMATED_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -67,7 +77,8 @@ public class EmoteStatsTest {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
EmoteStatsModel model = Mockito.mock(EmoteStatsModel.class);
|
||||
when(model.areStatsAvailable()).thenReturn(false);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -79,7 +90,8 @@ public class EmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getStaticEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(eq(noParameters.getUserInitiatedContext().getServer()), any(Instant.class))).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getActiveEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_STATIC_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package dev.sheldan.abstracto.statistic.emotes.command;
|
||||
|
||||
import dev.sheldan.abstracto.core.command.execution.CommandContext;
|
||||
import dev.sheldan.abstracto.core.models.database.AServer;
|
||||
import dev.sheldan.abstracto.core.service.ChannelService;
|
||||
import dev.sheldan.abstracto.core.service.management.ServerManagementService;
|
||||
import dev.sheldan.abstracto.core.test.command.CommandConfigValidator;
|
||||
import dev.sheldan.abstracto.core.test.command.CommandTestUtilities;
|
||||
import dev.sheldan.abstracto.statistic.config.StatisticFeatures;
|
||||
@@ -38,6 +40,12 @@ public class ExternalEmoteStatsTest {
|
||||
@Mock
|
||||
private ChannelService channelService;
|
||||
|
||||
@Mock
|
||||
private ServerManagementService serverManagementService;
|
||||
|
||||
@Mock
|
||||
private AServer server;
|
||||
|
||||
@Test
|
||||
public void testWithoutParameterStaticEmotes() {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
@@ -45,7 +53,8 @@ public class ExternalEmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getStaticEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -57,7 +66,8 @@ public class ExternalEmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getAnimatedEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_ANIMATED_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -67,7 +77,8 @@ public class ExternalEmoteStatsTest {
|
||||
CommandContext noParameters = CommandTestUtilities.getNoParameters();
|
||||
EmoteStatsModel model = Mockito.mock(EmoteStatsModel.class);
|
||||
when(model.areStatsAvailable()).thenReturn(false);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(noParameters.getUserInitiatedContext().getServer(), Instant.EPOCH)).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(server, Instant.EPOCH)).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(eq(EmoteStats.EMOTE_STATS_NO_STATS_AVAILABLE), any(), eq(noParameters.getChannel()))).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
@@ -79,7 +90,8 @@ public class ExternalEmoteStatsTest {
|
||||
EmoteStatsResultDisplay display = Mockito.mock(EmoteStatsResultDisplay.class);
|
||||
when(model.getStaticEmotes()).thenReturn(Arrays.asList(display));
|
||||
when(model.areStatsAvailable()).thenReturn(true);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(eq(noParameters.getUserInitiatedContext().getServer()), any(Instant.class))).thenReturn(model);
|
||||
when(serverManagementService.loadServer(noParameters.getGuild())).thenReturn(server);
|
||||
when(usedEmoteService.getExternalEmoteStatsForServerSince(eq(server), any(Instant.class))).thenReturn(model);
|
||||
when(channelService.sendEmbedTemplateInChannel(EMOTE_STATS_STATIC_EXTERNAL_RESPONSE, model, noParameters.getChannel())).thenReturn(CommandTestUtilities.messageFutureList());
|
||||
CommandTestUtilities.checkSuccessfulCompletionAsync(testUnit.executeAsync(noParameters));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user