From babf5f973ae09e65d03afc148b704b1d643c10c6 Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Sat, 28 Oct 2023 07:42:45 +0200 Subject: [PATCH] fix: use populated non-raw conf when checking if bridge_v2 is enabled --- apps/emqx_bridge/src/emqx_bridge_api.erl | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/apps/emqx_bridge/src/emqx_bridge_api.erl b/apps/emqx_bridge/src/emqx_bridge_api.erl index 949082606..79bb8d43a 100644 --- a/apps/emqx_bridge/src/emqx_bridge_api.erl +++ b/apps/emqx_bridge/src/emqx_bridge_api.erl @@ -737,13 +737,14 @@ is_bridge_enabled_v1(BridgeType, BridgeName) -> throw(not_found) end. -is_bridge_enabled_v2(BridgeType, BridgeName) -> - try emqx_bridge:lookup(BridgeType, binary_to_existing_atom(BridgeName)) of - {ok, #{raw_config := ConfMap}} -> - maps:get(<<"enable">>, ConfMap, false); - {error, not_found} -> - throw(not_found) +is_bridge_enabled_v2(BridgeV1Type, BridgeName) -> + BridgeV2Type = emqx_bridge_v2:bridge_v1_type_to_bridge_v2_type(BridgeV1Type), + try emqx:get_config([bridges_v2, BridgeV2Type, binary_to_existing_atom(BridgeName)]) of + ConfMap -> + maps:get(enable, ConfMap, true) catch + error:{config_not_found, _} -> + throw(not_found); error:badarg -> %% catch non-existing atom, %% none-existing atom means it is not available in config PT storage.