Software / code / prosody-modules
Comparison
mod_rest/jsonmap.lib.lua @ 3860:9752a6f1b9f3
mod_rest: Avoid treating special json.null value as any other table
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 25 Jan 2020 02:06:07 +0100 |
| parent | 3859:da3a0f055526 |
| child | 3870:3261a82884bb |
comparison
equal
deleted
inserted
replaced
| 3859:da3a0f055526 | 3860:9752a6f1b9f3 |
|---|---|
| 75 end | 75 end |
| 76 end | 76 end |
| 77 return { node = s.attr.node, identities = identities, features = features, }; | 77 return { node = s.attr.node, identities = identities, features = features, }; |
| 78 end; | 78 end; |
| 79 function (s) | 79 function (s) |
| 80 if type(s) == "table" then | 80 if type(s) == "table" and s ~= json.null then |
| 81 local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info", node = s.node }); | 81 local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info", node = s.node }); |
| 82 if s.identities then | 82 if s.identities then |
| 83 for _, identity in ipairs(s.identities) do | 83 for _, identity in ipairs(s.identities) do |
| 84 disco:tag("identity", { category = identity.category, type = identity.type, name = identity.name }):up(); | 84 disco:tag("identity", { category = identity.category, type = identity.type, name = identity.name }):up(); |
| 85 end | 85 end |
| 105 end | 105 end |
| 106 return items; | 106 return items; |
| 107 end; | 107 end; |
| 108 function (s) | 108 function (s) |
| 109 local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#items" }); | 109 local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#items" }); |
| 110 if type(s) == "table" then | 110 if type(s) == "table" and s ~= json.null then |
| 111 for _, item in ipairs(s) do | 111 for _, item in ipairs(s) do |
| 112 if type(item) == "string" then | 112 if type(item) == "string" then |
| 113 disco:tag("item", { jid = item }); | 113 disco:tag("item", { jid = item }); |
| 114 elseif type(item) == "table" then | 114 elseif type(item) == "table" then |
| 115 disco:tag("item", { jid = item.jid, node = item.node, name = item.name }); | 115 disco:tag("item", { jid = item.jid, node = item.node, name = item.name }); |