mirror of
https://github.com/Sheldan/abstracto.git
synced 2026-03-23 05:26:06 +00:00
added initial setting for the mod mail category in a listener, so it can be configured via command
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
package dev.sheldan.abstracto.modmail.listener;
|
||||
|
||||
import dev.sheldan.abstracto.core.listener.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 org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ModMailConfigListener implements ServerConfigListener {
|
||||
|
||||
@Autowired
|
||||
private ConfigManagementService configService;
|
||||
|
||||
@Override
|
||||
public void updateServerConfig(AServer server) {
|
||||
configService.createIfNotExists(server.getId(), ModMailThreadServiceBean.MODMAIL_CATEGORY, 0L);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,15 @@ public class ConfigManagementServiceBean implements ConfigManagementService {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AConfig createIfNotExists(Long serverId, String name, Long value) {
|
||||
AConfig config = loadConfig(serverId, name);
|
||||
if(config == null) {
|
||||
return this.createConfig(serverId, name, value);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AConfig createIfNotExists(Long serverId, String name, Double value) {
|
||||
AConfig config = loadConfig(serverId, name);
|
||||
|
||||
@@ -9,6 +9,7 @@ public interface ConfigManagementService {
|
||||
AConfig createConfig(Long serverId, String name, Double value);
|
||||
AConfig createConfig(Long serverId, String name, Long value);
|
||||
AConfig createIfNotExists(Long serverId, String name, String value);
|
||||
AConfig createIfNotExists(Long serverId, String name, Long value);
|
||||
AConfig createIfNotExists(Long serverId, String name, Double value);
|
||||
AConfig loadConfig(Long serverId, String name);
|
||||
boolean configExists(Long serverId, String name);
|
||||
|
||||
Reference in New Issue
Block a user