Просмотр исходного кода

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'
```
terry-xiaoyu 5 лет назад
Родитель
Сommit
211c800e24
1 измененных файлов с 11 добавлено и 1 удалено
  1. 11 1
      src/emqx_message.erl

+ 11 - 1
src/emqx_message.erl

@@ -250,11 +250,21 @@ to_packet(PacketId, Msg = #message{qos = QoS, headers = Headers,
                                                },
                  variable = #mqtt_packet_publish{topic_name = Topic,
                                                  packet_id  = PacketId,
-                                                 properties = maps:get(properties, Headers, #{})
+                                                 properties = filter_pub_props(maps:get(properties, Headers, #{}))
                                                 },
                  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
 -spec(to_map(emqx_types:message()) -> map()).
 to_map(#message{