fix(properties): downlink will msg contains non-publish properties

The paho test failed because the client received a will message
that has an `Will-Delay-Interval` property.

All the 7 allowed PUBLISH properties are listed as follows:

```
'Payload-Format-Indicator',
'Message-Expiry-Interval',
'Response-Topic',
'Correlation-Data',
'User-Property',
'Subscription-Identifier',
'Content-Type'
```
This commit is contained in:
terry-xiaoyu 2020-06-21 11:23:46 +08:00
parent 600b1055f3
commit 211c800e24
1 changed files with 11 additions and 1 deletions

View File

@ -250,11 +250,21 @@ to_packet(PacketId, Msg = #message{qos = QoS, headers = Headers,
}, },
variable = #mqtt_packet_publish{topic_name = Topic, variable = #mqtt_packet_publish{topic_name = Topic,
packet_id = PacketId, packet_id = PacketId,
properties = maps:get(properties, Headers, #{}) properties = filter_pub_props(maps:get(properties, Headers, #{}))
}, },
payload = Payload payload = Payload
}. }.
filter_pub_props(Props) ->
maps:with(['Payload-Format-Indicator',
'Message-Expiry-Interval',
'Response-Topic',
'Correlation-Data',
'User-Property',
'Subscription-Identifier',
'Content-Type'
], Props).
%% @doc Message to map %% @doc Message to map
-spec(to_map(emqx_types:message()) -> map()). -spec(to_map(emqx_types:message()) -> map()).
to_map(#message{ to_map(#message{