diff --git a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java index 1f21df2471..f8252e49e9 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java +++ b/src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/BtnNetworkOnline.java @@ -37,16 +37,12 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; import static com.ghostchu.peerbanhelper.text.TextManager.tl; import static com.ghostchu.peerbanhelper.text.TextManager.tlUI; @@ -91,11 +87,17 @@ public void onEnable() { } private void status(Context context) { + Map info = new HashMap<>(); if (btnNetwork == null) { + info.put("configSuccess", false); + info.put("appId", "N/A"); + info.put("appSecret", "N/A"); + info.put("abilities", Collections.emptyList()); + info.put("configUrl", tl(locale(context), Lang.BTN_SERVICES_NEED_RESTART)); context.json(new StdResp(false, tl(locale(context), Lang.BTN_NOT_ENABLE_AND_REQUIRE_RESTART), null)); return; } - Map info = new HashMap<>(); + info.put("configSuccess", btnNetwork.getConfigSuccess()); var abilities = new ArrayList<>(); for (Map.Entry, BtnAbility> entry : btnNetwork.getAbilities().entrySet()) { diff --git a/src/main/java/com/ghostchu/peerbanhelper/text/Lang.java b/src/main/java/com/ghostchu/peerbanhelper/text/Lang.java index c8715a1e04..9dab3d6bc4 100644 --- a/src/main/java/com/ghostchu/peerbanhelper/text/Lang.java +++ b/src/main/java/com/ghostchu/peerbanhelper/text/Lang.java @@ -419,8 +419,20 @@ public enum Lang { MODULE_AMM_TRAFFIC_MONITORING_TRAFFIC_ALERT_TITLE, MODULE_AMM_TRAFFIC_MONITORING_TRAFFIC_ALERT_DESCRIPTION, DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_TITLE, - DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION, DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION_FALLBACK, PROGRAM_OUT_OF_MEMORY_TITLE, PROGRAM_OUT_OF_MEMORY_DESCRIPTION, BAN_PEER_EXCEPTION, - PUSH_PROVIDER_TEST_TITLE, PUSH_PROVIDER_TEST_DESCRIPTION, PUSH_PROVIDER_TEST_SUCCESS, PUSH_PROVIDER_TEST_FAILED, PUSH_PROVIDER_TEST_ERROR, EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS, BTN_RULES_SCRIPT_COMPILING, BTN_RULES_SCRIPT_COMPILED; + DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION, + DOWNLOADER_ALERT_TOO_MANY_FAILED_ATTEMPT_DESCRIPTION_FALLBACK, + PROGRAM_OUT_OF_MEMORY_TITLE, + PROGRAM_OUT_OF_MEMORY_DESCRIPTION, + BAN_PEER_EXCEPTION, + PUSH_PROVIDER_TEST_TITLE, + PUSH_PROVIDER_TEST_DESCRIPTION, + PUSH_PROVIDER_TEST_SUCCESS, + PUSH_PROVIDER_TEST_FAILED, + PUSH_PROVIDER_TEST_ERROR, + EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS, + BTN_RULES_SCRIPT_COMPILING, + BTN_RULES_SCRIPT_COMPILED, + BTN_SERVICES_NEED_RESTART; public String getKey() { return name(); diff --git a/src/main/resources/lang/en_us/messages.yml b/src/main/resources/lang/en_us/messages.yml index aaaa9e362b..7b96bb7e8a 100644 --- a/src/main/resources/lang/en_us/messages.yml +++ b/src/main/resources/lang/en_us/messages.yml @@ -483,3 +483,4 @@ EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS: "For security reason, create EXPRESS_RULE_ENGINE_SAVED: "Script saved" BTN_RULES_SCRIPT_COMPILING: "Compiling the scripts from BTN server, this may take a while..." BTN_RULES_SCRIPT_COMPILED: "Compiled {} scripts, took {}ms" +BTN_SERVICES_NEED_RESTART: "BTN Service Unavailable: Restart PeerBanHelper is required for loading BTN module and apply changes." \ No newline at end of file diff --git a/src/main/resources/lang/messages_fallback.yml b/src/main/resources/lang/messages_fallback.yml index 2850461ee1..01e28e5588 100644 --- a/src/main/resources/lang/messages_fallback.yml +++ b/src/main/resources/lang/messages_fallback.yml @@ -481,3 +481,4 @@ EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS: "因安全原因,不允许 EXPRESS_RULE_ENGINE_SAVED: "脚本已保存" BTN_RULES_SCRIPT_COMPILING: "正在编译来自 BTN 服务器的可编程脚本,请稍等,这可能需要一点时间……" BTN_RULES_SCRIPT_COMPILED: "已成功编译 {} 个脚本,用时 {}ms" +BTN_SERVICES_NEED_RESTART: "BTN 服务不可用:需要重启 PeerBanHelper 以加载 BTN 模块并应用更改" \ No newline at end of file diff --git a/src/main/resources/lang/zh_cn/messages.yml b/src/main/resources/lang/zh_cn/messages.yml index 2850461ee1..01e28e5588 100644 --- a/src/main/resources/lang/zh_cn/messages.yml +++ b/src/main/resources/lang/zh_cn/messages.yml @@ -481,3 +481,4 @@ EXPRESS_RULE_ENGINE_DISALLOW_UNSAFE_SOURCE_ACCESS: "因安全原因,不允许 EXPRESS_RULE_ENGINE_SAVED: "脚本已保存" BTN_RULES_SCRIPT_COMPILING: "正在编译来自 BTN 服务器的可编程脚本,请稍等,这可能需要一点时间……" BTN_RULES_SCRIPT_COMPILED: "已成功编译 {} 个脚本,用时 {}ms" +BTN_SERVICES_NEED_RESTART: "BTN 服务不可用:需要重启 PeerBanHelper 以加载 BTN 模块并应用更改" \ No newline at end of file