feat: 修改从gitea上获取配置的逻辑
All checks were successful
Redis序列化结构检查 / redis-schema-check (push) Has been skipped
All checks were successful
Redis序列化结构检查 / redis-schema-check (push) Has been skipped
This commit is contained in:
@@ -85,7 +85,7 @@ public final class ConfigLoader {
|
||||
Map<String, Object> notify = asMap(map.get("notify"));
|
||||
CheckerConfig.Notify n = config.getNotify();
|
||||
n.setEnabled(bool(notify, "enabled", true));
|
||||
n.setWebhookEnv(str(notify, "webhook_env", "WECOM_ROBOT_WEBHOOK"));
|
||||
n.setWebhookUrl(resolveWebhookUrl(notify));
|
||||
n.setNotifyOnClean(bool(notify, "notify_on_clean", false));
|
||||
n.setTitlePrefix(str(notify, "title_prefix", "[Redis结构变更]"));
|
||||
|
||||
@@ -137,6 +137,21 @@ public final class ConfigLoader {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* 优先读取 webhook_url;兼容旧字段 webhook_env(值为 http 开头时视为 URL)。
|
||||
*/
|
||||
private static String resolveWebhookUrl(Map<String, Object> notify) {
|
||||
String url = str(notify, "webhook_url", "");
|
||||
if (url != null && !url.trim().isEmpty()) {
|
||||
return url.trim();
|
||||
}
|
||||
String legacy = str(notify, "webhook_env", "");
|
||||
if (legacy != null && legacy.trim().startsWith("http")) {
|
||||
return legacy.trim();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Map<String, Object> asMap(Object obj) {
|
||||
if (obj instanceof Map) {
|
||||
|
||||
Reference in New Issue
Block a user