Merge pull request #1802 from Gilbert-Wong/emqx30

Add pattern match for topic alias
This commit is contained in:
Shawn 2018-09-08 12:58:43 +08:00 committed by GitHub
commit e199e29b67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -647,11 +647,17 @@ check_publish(Packet, PState) ->
run_check_steps([fun check_pub_caps/2, run_check_steps([fun check_pub_caps/2,
fun check_pub_acl/2], Packet, PState). fun check_pub_acl/2], Packet, PState).
check_pub_caps(#mqtt_packet{header = #mqtt_packet_header{qos = QoS, retain = Retain},
variable = #mqtt_packet_publish{
properties = #{'Topic-Alias' := TopicAlias}
}},
#pstate{zone = Zone}) ->
emqx_mqtt_caps:check_pub(Zone, #{qos => QoS, retain => Retain, topic_alias => TopicAlias});
check_pub_caps(#mqtt_packet{header = #mqtt_packet_header{qos = QoS, retain = Retain}, check_pub_caps(#mqtt_packet{header = #mqtt_packet_header{qos = QoS, retain = Retain},
variable = #mqtt_packet_publish{ properties = Properties}}, variable = #mqtt_packet_publish{ properties = Properties}},
#pstate{zone = Zone}) -> #pstate{zone = Zone}) ->
#{'Topic-Alias' := TopicAlias} = Properties, emqx_mqtt_caps:check_pub(Zone, #{qos => QoS, retain => Retain}).
emqx_mqtt_caps:check_pub(Zone, #{qos => QoS, retain => Retain, topic_alias => TopicAlias}).
check_pub_acl(_Packet, #pstate{is_super = IsSuper, enable_acl = EnableAcl}) check_pub_acl(_Packet, #pstate{is_super = IsSuper, enable_acl = EnableAcl})
when IsSuper orelse (not EnableAcl) -> when IsSuper orelse (not EnableAcl) ->