fix(mqtt-cap): use global config as defaults

Don't use default values in module, use global mqtt config as default
This commit is contained in:
William Yang 2023-05-02 12:36:34 +02:00
parent 9903f34470
commit be6cd5705f
2 changed files with 16 additions and 14 deletions

View File

@ -58,18 +58,18 @@
exclusive_subscription exclusive_subscription
]). ]).
-define(DEFAULT_CAPS, #{ -define(DEFAULT_CAPS_KEYS, [
max_packet_size => ?MAX_PACKET_SIZE, max_packet_size,
max_clientid_len => ?MAX_CLIENTID_LEN, max_clientid_len,
max_topic_alias => ?MAX_TOPIC_AlIAS, max_topic_alias,
max_topic_levels => ?MAX_TOPIC_LEVELS, max_topic_levels,
max_qos_allowed => ?QOS_2, max_qos_allowed,
retain_available => true, retain_available,
wildcard_subscription => true, wildcard_subscription,
subscription_identifiers => true, subscription_identifiers,
shared_subscription => true, shared_subscription,
exclusive_subscription => false exclusive_subscription
}). ]).
-spec check_pub( -spec check_pub(
emqx_types:zone(), emqx_types:zone(),
@ -152,12 +152,12 @@ do_check_sub(_Flags, _Caps, _, _) ->
ok. ok.
get_caps(Zone) -> get_caps(Zone) ->
get_caps(maps:keys(?DEFAULT_CAPS), Zone). get_caps(?DEFAULT_CAPS_KEYS, Zone).
get_caps(Keys, Zone) -> get_caps(Keys, Zone) ->
maps:with( maps:with(
Keys, Keys,
maps:merge( maps:merge(
?DEFAULT_CAPS, emqx_config:get([mqtt]),
emqx_config:get_zone_conf(Zone, [mqtt]) emqx_config:get_zone_conf(Zone, [mqtt])
) )
). ).

View File

@ -267,6 +267,8 @@ t_chan_info(_) ->
t_chan_caps(_) -> t_chan_caps(_) ->
?assertMatch( ?assertMatch(
#{ #{
exclusive_subscription := false,
max_packet_size := 1048576,
max_clientid_len := 65535, max_clientid_len := 65535,
max_qos_allowed := 2, max_qos_allowed := 2,
max_topic_alias := 65535, max_topic_alias := 65535,