comparison mod_rest/jsonmap.lib.lua @ 3871:e5d08bb58155

mod_rest: Map the error@by attribute
author Kim Alvefur <zash@zash.se>
date Sat, 01 Feb 2020 00:38:10 +0100
parents 3261a82884bb
children 93f71ab6cb00
comparison
equal deleted inserted replaced
3870:3261a82884bb 3871:e5d08bb58155
201 t.from = jid.prep(t.from); 201 t.from = jid.prep(t.from);
202 if not t.from then return nil, "invalid-jid-from"; end 202 if not t.from then return nil, "invalid-jid-from"; end
203 end 203 end
204 204
205 if t.type == "error" then 205 if t.type == "error" then
206 local error = s:get_child("error");
206 local err_typ, err_condition, err_text = s:get_error(); 207 local err_typ, err_condition, err_text = s:get_error();
207 t.error = { 208 t.error = {
208 type = err_typ, 209 type = err_typ,
209 condition = err_condition, 210 condition = err_condition,
210 text = err_text 211 text = err_text,
212 by = error.attr.by,
211 }; 213 };
212 return t; 214 return t;
213 end 215 end
214 216
215 for k, typ in pairs(simple_types) do 217 for k, typ in pairs(simple_types) do
279 if kind == "iq" and not s.attr.type then 281 if kind == "iq" and not s.attr.type then
280 s.attr.type = "get"; 282 s.attr.type = "get";
281 end 283 end
282 284
283 if type(t.error) == "table" then 285 if type(t.error) == "table" then
284 return st.error_reply(st.reply(s), str(t.error.type), str(t.error.condition), str(t.error.text)); 286 return st.error_reply(st.reply(s), str(t.error.type), str(t.error.condition), str(t.error.text), str(t.error.by));
285 elseif t.type == "error" then 287 elseif t.type == "error" then
286 s:text_tag("error", t.body, { code = t.error_code and tostring(t.error_code) }); 288 s:text_tag("error", t.body, { code = t.error_code and tostring(t.error_code) });
287 return s; 289 return s;
288 end 290 end
289 291