[AB-149] adding command to reset configuration to default values

removing listener to create system config instances
adding default value retrieval to appropriate places
making config key handling case insensitive
changing exp multiplier to double value
refactoring experience service bean test
This commit is contained in:
Sheldan
2021-02-24 21:11:01 +01:00
parent 20b6b37151
commit 5f6746d742
35 changed files with 613 additions and 560 deletions

View File

@@ -1,36 +0,0 @@
package dev.sheldan.abstracto.modmail.listener;
import dev.sheldan.abstracto.core.listener.sync.entity.ServerConfigListener;
import dev.sheldan.abstracto.core.models.database.AServer;
import dev.sheldan.abstracto.core.service.management.ConfigManagementService;
import dev.sheldan.abstracto.modmail.service.ModMailThreadServiceBean;
import dev.sheldan.abstracto.core.templating.service.TemplateService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import static dev.sheldan.abstracto.modmail.service.ModMailThreadServiceBean.MODMAIL_CLOSING_MESSAGE_TEXT;
/**
* This listener is used to used to set the initial values of some server specific values, so we don't need to fall
* back to the default values. The values might not be functional, for example mod mail category id, but their existence
* makes things easier
*/
@Component
@Slf4j
public class ModMailConfigListener implements ServerConfigListener {
@Autowired
private ConfigManagementService configService;
@Autowired
private TemplateService templateService;
@Override
public void updateServerConfig(AServer server) {
log.info("Updating modmail related configuration for server {}.", server.getId());
configService.loadOrCreateIfNotExists(server.getId(), ModMailThreadServiceBean.MODMAIL_CATEGORY, 0L);
configService.loadOrCreateIfNotExists(server.getId(), MODMAIL_CLOSING_MESSAGE_TEXT, templateService.renderSimpleTemplate("modmail_closing_user_message_description"));
}
}