Comparison

mod_rest/jsonmap.lib.lua @ 3852:66f96b98d219

mod_rest: Allow returning an array of JID strings as disco#items
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2020 00:30:14 +0100
parent 3851:8dbca6a93988
child 3854:25c34c9f755c
comparison
equal deleted inserted replaced
3851:8dbca6a93988 3852:66f96b98d219
85 end; 85 end;
86 function (s) 86 function (s)
87 local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#items" }); 87 local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#items" });
88 if type(s) == "table" then 88 if type(s) == "table" then
89 for _, item in ipairs(s) do 89 for _, item in ipairs(s) do
90 disco:tag("item", { jid = item.jid, node = item.node, name = item.name }); 90 if type(item) == "string" then
91 disco:tag("item", { jid = item });
92 elseif type(item) == "table" then
93 disco:tag("item", { jid = item.jid, node = item.node, name = item.name });
94 end
91 end 95 end
92 end 96 end
93 return disco; 97 return disco;
94 end; 98 end;
95 }; 99 };