comparison mod_cloud_notify/mod_cloud_notify.lua @ 2050:49cc6a555dc7

mod_cloud_notify: Wrap form in namespaced element per the XEP (fixes #630)
author Kim Alvefur <zash@zash.se>
date Thu, 18 Feb 2016 22:37:50 +0100
parents 980e5f5bd62c
children cb0fc00a7086
comparison
equal deleted inserted replaced
2049:50c188cf0ae3 2050:49cc6a555dc7
90 local push_jid, push_node = push_info.jid, push_info.node; 90 local push_jid, push_node = push_info.jid, push_info.node;
91 local push_publish = st.iq({ to = push_jid, from = node .. "@" .. module.host, type = "set", id = "push" }) 91 local push_publish = st.iq({ to = push_jid, from = node .. "@" .. module.host, type = "set", id = "push" })
92 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) 92 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" })
93 :tag("publish", { node = push_node }) 93 :tag("publish", { node = push_node })
94 :tag("item"); 94 :tag("item");
95 :tag("notification", { xmlns = xmlns_push });
95 local form_data = { 96 local form_data = {
96 ["message-count"] = tostring(push_info.count); 97 ["message-count"] = tostring(push_info.count);
97 }; 98 };
98 if include_sender then 99 if include_sender then
99 form_data["last-message-sender"] = stanza.attr.from; 100 form_data["last-message-sender"] = stanza.attr.from;
100 end 101 end
101 if include_body then 102 if include_body then
102 form_data["last-message-body"] = stanza:get_child_text("body"); 103 form_data["last-message-body"] = stanza:get_child_text("body");
103 end 104 end
104 push_publish:add_child(push_form:form(form_data)); 105 push_publish:add_child(push_form:form(form_data));
106 push_publish:up(); -- / notification
105 push_publish:up(); -- / publish 107 push_publish:up(); -- / publish
106 push_publish:up(); -- / pubsub 108 push_publish:up(); -- / pubsub
107 if push_info.options then 109 if push_info.options then
108 push_publish:tag("publish-options"):add_child(push_info.options); 110 push_publish:tag("publish-options"):add_child(push_info.options);
109 end 111 end