added message to user initiated context

fixed templates for ban and kick logging
refactored kicking service
fixed guild not found exception template
added command validator to be used for unit testing commands
added default values for command configuration
changed some interfaces to message channel instead of text channel
added separate executor service for un-mutes, which is shared
updated spring boot version to 2.3.1
removed database connection string from properties
added logback configuration
changed some future logic in purge
refactored error message for un mute, when there is no active mute
refactored listener interface and removed usage of context utils
added tests for moderation services
This commit is contained in:
Sheldan
2020-06-20 11:08:44 +02:00
parent 8acd4f818d
commit c44eb80fc5
140 changed files with 4176 additions and 225 deletions

View File

@@ -40,7 +40,6 @@ public class Remind extends AbstractConditionableCommand {
String text = (String) parameters.get(1);
AUserInAServer aUserInAServer = commandContext.getUserInitiatedContext().getAUserInAServer();
ReminderModel remindModel = (ReminderModel) ContextConverter.fromCommandContext(commandContext, ReminderModel.class);
remindModel.setMessage(commandContext.getMessage());
remindModel.setRemindText(text);
Reminder createdReminder = remindService.createReminderInForUser(aUserInAServer, text, remindTime, commandContext.getMessage());
remindModel.setReminder(createdReminder);

View File

@@ -0,0 +1,17 @@
package dev.sheldan.abstracto.utility.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
@Configuration
public class UtilitySpringConfig {
@Bean(name = "reminderScheduler")
public ScheduledExecutorService getUnMuteExecutor() {
return Executors.newScheduledThreadPool(1);
}
}

View File

@@ -2,6 +2,8 @@ package dev.sheldan.abstracto.utility.listener.starboard;
import dev.sheldan.abstracto.core.config.FeatureEnum;
import dev.sheldan.abstracto.core.listener.MessageDeletedListener;
import dev.sheldan.abstracto.core.models.AServerAChannelAUser;
import dev.sheldan.abstracto.core.models.GuildChannelMember;
import dev.sheldan.abstracto.core.models.cache.CachedMessage;
import dev.sheldan.abstracto.utility.config.features.UtilityFeature;
import dev.sheldan.abstracto.utility.models.database.StarboardPost;
@@ -20,7 +22,7 @@ public class StarboardPostDeletedListener implements MessageDeletedListener {
private StarboardPostManagementService starboardPostManagementService;
@Override
public void execute(CachedMessage messageBefore) {
public void execute(CachedMessage messageBefore, AServerAChannelAUser authorUser, GuildChannelMember authorMember) {
Optional<StarboardPost> byStarboardPostId = starboardPostManagementService.findByStarboardPostId(messageBefore.getMessageId());
if(byStarboardPostId.isPresent()) {
StarboardPost post = byStarboardPostId.get();

View File

@@ -23,6 +23,7 @@ import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.TextChannel;
import org.quartz.JobDataMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@@ -57,6 +58,10 @@ public class RemindServiceBean implements ReminderService {
@Autowired
private ChannelService channelService;
@Autowired
@Qualifier("reminderScheduler")
private ScheduledExecutorService instantReminderScheduler;
@Override
public Reminder createReminderInForUser(AUserInAServer user, String remindText, Duration remindIn, Message message) {
AChannel channel = channelManagementService.loadChannel(message.getChannel().getIdLong()).orElseThrow(() -> new ChannelNotFoundException(message.getChannel().getIdLong(), message.getGuild().getIdLong()));
@@ -74,9 +79,7 @@ public class RemindServiceBean implements ReminderService {
if(remindIn.getSeconds() < 60) {
log.trace("Directly scheduling the reminder, because it was below the threshold.");
// TODO make a bean out of this
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.schedule(() -> {
instantReminderScheduler.schedule(() -> {
try {
self.executeReminder(reminder.getId());
} catch (Exception exception) {