Comparison

mod_smacks/mod_smacks.lua @ 2937:e672d1050529

mod_smacks: Ensure stanza count attributes are always strings (thanks Martin)
author Matthew Wild <mwild1@gmail.com>
date Sat, 17 Mar 2018 12:58:37 +0000
parent 2756:dbba101601b4
child 3104:626d2c781c66
comparison
equal deleted inserted replaced
2936:4fed2379f5be 2937:e672d1050529
234 old_session_registry.set(session.username, session.resumption_token, nil); 234 old_session_registry.set(session.username, session.resumption_token, nil);
235 session.resumption_token = nil; 235 session.resumption_token = nil;
236 end 236 end
237 -- send out last ack as per revision 1.5.2 of XEP-0198 237 -- send out last ack as per revision 1.5.2 of XEP-0198
238 if session.smacks and session.conn then 238 if session.smacks and session.conn then
239 (session.sends2s or session.send)(st.stanza("a", { xmlns = session.smacks, h = tostring(session.handled_stanza_count) })); 239 (session.sends2s or session.send)(st.stanza("a", { xmlns = session.smacks, h = string.format("%d", session.handled_stanza_count) }));
240 end 240 end
241 return session_close(...); 241 return session_close(...);
242 end 242 end
243 return session; 243 return session;
244 end 244 end
320 module:log("debug", "Received ack request from non-smack-enabled session"); 320 module:log("debug", "Received ack request from non-smack-enabled session");
321 return; 321 return;
322 end 322 end
323 module:log("debug", "Received ack request, acking for %d", origin.handled_stanza_count); 323 module:log("debug", "Received ack request, acking for %d", origin.handled_stanza_count);
324 -- Reply with <a> 324 -- Reply with <a>
325 (origin.sends2s or origin.send)(st.stanza("a", { xmlns = xmlns_sm, h = tostring(origin.handled_stanza_count) })); 325 (origin.sends2s or origin.send)(st.stanza("a", { xmlns = xmlns_sm, h = string.format("%d", origin.handled_stanza_count) }));
326 return true; 326 return true;
327 end 327 end
328 module:hook_stanza(xmlns_sm2, "r", function (origin, stanza) return handle_r(origin, stanza, xmlns_sm2); end); 328 module:hook_stanza(xmlns_sm2, "r", function (origin, stanza) return handle_r(origin, stanza, xmlns_sm2); end);
329 module:hook_stanza(xmlns_sm3, "r", function (origin, stanza) return handle_r(origin, stanza, xmlns_sm3); end); 329 module:hook_stanza(xmlns_sm3, "r", function (origin, stanza) return handle_r(origin, stanza, xmlns_sm3); end);
330 330
468 session.log("debug", "Tried to resume non-existent session with id %s", id); 468 session.log("debug", "Tried to resume non-existent session with id %s", id);
469 local old_session = old_session_registry.get(session.username, id); 469 local old_session = old_session_registry.get(session.username, id);
470 if old_session and session.username == old_session.username 470 if old_session and session.username == old_session.username
471 and session.host == old_session.host 471 and session.host == old_session.host
472 and old_session.h then 472 and old_session.h then
473 session.send(st.stanza("failed", { xmlns = xmlns_sm, h = tostring(old_session.h) }) 473 session.send(st.stanza("failed", { xmlns = xmlns_sm, h = string.format("%d", old_session.h) })
474 :tag("item-not-found", { xmlns = xmlns_errors }) 474 :tag("item-not-found", { xmlns = xmlns_errors })
475 ); 475 );
476 else 476 else
477 session.send(st.stanza("failed", { xmlns = xmlns_sm }) 477 session.send(st.stanza("failed", { xmlns = xmlns_sm })
478 :tag("item-not-found", { xmlns = xmlns_errors }) 478 :tag("item-not-found", { xmlns = xmlns_errors })
503 original_session.stream:set_session(original_session); 503 original_session.stream:set_session(original_session);
504 -- Similar for connlisteners 504 -- Similar for connlisteners
505 c2s_sessions[session.conn] = original_session; 505 c2s_sessions[session.conn] = original_session;
506 506
507 original_session.send(st.stanza("resumed", { xmlns = xmlns_sm, 507 original_session.send(st.stanza("resumed", { xmlns = xmlns_sm,
508 h = original_session.handled_stanza_count, previd = id })); 508 h = string.format("%d", original_session.handled_stanza_count), previd = id }));
509 509
510 -- Fake an <a> with the h of the <resume/> from the client 510 -- Fake an <a> with the h of the <resume/> from the client
511 original_session:dispatch_stanza(st.stanza("a", { xmlns = xmlns_sm, 511 original_session:dispatch_stanza(st.stanza("a", { xmlns = xmlns_sm,
512 h = stanza.attr.h })); 512 h = stanza.attr.h }));
513 513