Comparison

util/stanza.lua @ 9732:51583ea2b4fd

util.stanza: Require a type attribute for iq stanzas
author Kim Alvefur <zash@zash.se>
date Fri, 28 Dec 2018 20:49:01 +0100
parent 9674:6f97acc4583b
child 9924:5a2e53bef031
comparison
equal deleted inserted replaced
9731:47121e8dc5b1 9732:51583ea2b4fd
421 else 421 else
422 return new_stanza("message", attr):tag("body"):text(body):up(); 422 return new_stanza("message", attr):tag("body"):text(body):up();
423 end 423 end
424 end 424 end
425 local function iq(attr) 425 local function iq(attr)
426 if not (attr and attr.id) then 426 if not attr then
427 error("iq stanzas require id and type attributes");
428 end
429 if not attr.id then
427 error("iq stanzas require an id attribute"); 430 error("iq stanzas require an id attribute");
431 end
432 if not attr.type then
433 error("iq stanzas require a type attribute");
428 end 434 end
429 return new_stanza("iq", attr); 435 return new_stanza("iq", attr);
430 end 436 end
431 437
432 local function reply(orig) 438 local function reply(orig)