comparison mod_rest/jsonmap.lib.lua @ 3886:b64b08b7bf8e

mod_rest: Ignore already handled top-level stanza attr fields Prevents the check in 1ec45dbc7db5 from returning an error for these fields that aren't handled in that loop.
author Kim Alvefur <zash@zash.se>
date Fri, 07 Feb 2020 20:53:57 +0100
parents 1ec45dbc7db5
children 04ea96a0488d
comparison
equal deleted inserted replaced
3885:1ec45dbc7db5 3886:b64b08b7bf8e
88 end 88 end
89 end; 89 end;
90 }; 90 };
91 91
92 local simple_types = { 92 local simple_types = {
93 -- top level stanza attributes
94 -- needed here to mark them as known fields
95 kind = "attr",
96 type = "attr",
97 to = "attr",
98 from = "attr",
99 id = "attr",
100
93 -- basic message 101 -- basic message
94 body = "text_tag", 102 body = "text_tag",
95 subject = "text_tag", 103 subject = "text_tag",
96 thread = "text_tag", 104 thread = "text_tag",
97 105
451 for k, v in pairs(t) do 459 for k, v in pairs(t) do
452 local typ = simple_types[k]; 460 local typ = simple_types[k];
453 if typ then 461 if typ then
454 if typ == "text_tag" then 462 if typ == "text_tag" then
455 s:text_tag(k, v); 463 s:text_tag(k, v);
464 elseif typ == "attr" then -- luacheck: ignore 542
465 -- handled already
456 elseif typ[1] == "text_tag" then 466 elseif typ[1] == "text_tag" then
457 s:text_tag(typ[3] or k, v, typ[2] and { xmlns = typ[2] }); 467 s:text_tag(typ[3] or k, v, typ[2] and { xmlns = typ[2] });
458 elseif typ[1] == "name" then 468 elseif typ[1] == "name" then
459 s:tag(v, { xmlns = typ[2] }):up(); 469 s:tag(v, { xmlns = typ[2] }):up();
460 elseif typ[1] == "attr" then 470 elseif typ[1] == "attr" then