comparison mod_rest/mod_rest.lua @ 4944:e67cc71727ca

mod_rest: Fix attempt to index nil in handling of single iq response Fix handling of many responses, break handling of single response :(
author Kim Alvefur <zash@zash.se>
date Tue, 17 May 2022 11:44:44 +0200
parents 83a54f4af94c
children 537054999093
comparison
equal deleted inserted replaced
4943:83a54f4af94c 4944:e67cc71727ca
387 387
388 local p = module:send_iq(payload, origin):next( 388 local p = module:send_iq(payload, origin):next(
389 function (result) 389 function (result)
390 module:log("debug", "Sending[rest]: %s", result.stanza:top_tag()); 390 module:log("debug", "Sending[rest]: %s", result.stanza:top_tag());
391 response.headers.content_type = send_type; 391 response.headers.content_type = send_type;
392 local tail = responses[#responses]; 392 if responses[1] then
393 if tail.name ~= "iq" or tail.attr.from ~= result.stanza.attr.from or tail.attr.id ~= result.stanza.attr.id then 393 local tail = responses[#responses];
394 origin.send(result.stanza); 394 if tail.name ~= "iq" or tail.attr.from ~= result.stanza.attr.from or tail.attr.id ~= result.stanza.attr.id then
395 origin.send(result.stanza);
396 end
395 end 397 end
396 if responses[2] then 398 if responses[2] then
397 return encode(send_type, responses); 399 return encode(send_type, responses);
398 end 400 end
399 return encode(send_type, result.stanza); 401 return encode(send_type, result.stanza);