Comparison

mod_pubsub_mqtt/mod_pubsub_mqtt.lua @ 5111:6ba2188e2686

mod_pubsub_mqtt: Add XEP-0060 <item> wrapper to payloads
author Matthew Wild <mwild1@gmail.com>
date Fri, 16 Dec 2022 12:11:16 +0000
parent 1343:7dbde05b48a9
child 5112:9499b88f3453
comparison
equal deleted inserted replaced
5110:43b67142b37c 5111:6ba2188e2686
39 module:log("warn", "Unable to locate host/node: %s", packet.topic); 39 module:log("warn", "Unable to locate host/node: %s", packet.topic);
40 return; 40 return;
41 end 41 end
42 local id = "mqtt"; 42 local id = "mqtt";
43 local ok, err = pubsub:publish(node, true, id, 43 local ok, err = pubsub:publish(node, true, id,
44 st.stanza("data", { xmlns = "https://prosody.im/protocol/data" }) 44 st.stanza("item", { xmlns = "http://jabber.org/protocol/pubsub", id = id })
45 :text(packet.data) 45 :text_tag("data", packet.data, { xmlns = "https://prosody.im/protocol/data" })
46 ); 46 );
47 if not ok then 47 if not ok then
48 module:log("warn", "Error publishing MQTT data: %s", tostring(err)); 48 module:log("warn", "Error publishing MQTT data: %s", tostring(err));
49 end 49 end
50 end 50 end