Comparison

plugins/mod_smacks.lua @ 12080:9744a0ceb767

mod_smacks: Only include max resumption time when resumption is activated
author Kim Alvefur <zash@zash.se>
date Mon, 20 Dec 2021 00:18:47 +0100
parent 12078:2c13aaae35ac
child 12081:6cc3135138d7
comparison
equal deleted inserted replaced
12079:76a5c0261793 12080:9744a0ceb767
253 module:log("debug", "Enabling stream management"); 253 module:log("debug", "Enabling stream management");
254 session.smacks = xmlns_sm; 254 session.smacks = xmlns_sm;
255 255
256 wrap_session(session, false); 256 wrap_session(session, false);
257 257
258 local resume_max;
258 local resume_token; 259 local resume_token;
259 local resume = stanza.attr.resume; 260 local resume = stanza.attr.resume;
260 if resume == "true" or resume == "1" then 261 if resume == "true" or resume == "1" then
261 resume_token = uuid_generate(); 262 resume_token = uuid_generate();
262 session_registry[jid.join(session.username, session.host, resume_token)] = session; 263 session_registry[jid.join(session.username, session.host, resume_token)] = session;
263 session.resumption_token = resume_token; 264 session.resumption_token = resume_token;
264 end 265 resume_max = tostring(resume_timeout);
265 (session.sends2s or session.send)(st.stanza("enabled", { xmlns = xmlns_sm, id = resume_token, resume = resume, max = tostring(resume_timeout) })); 266 end
267 (session.sends2s or session.send)(st.stanza("enabled", { xmlns = xmlns_sm, id = resume_token, resume = resume, max = resume_max }));
266 return true; 268 return true;
267 end 269 end
268 module:hook_tag(xmlns_sm2, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm2); end, 100); 270 module:hook_tag(xmlns_sm2, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm2); end, 100);
269 module:hook_tag(xmlns_sm3, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm3); end, 100); 271 module:hook_tag(xmlns_sm3, "enable", function (session, stanza) return handle_enable(session, stanza, xmlns_sm3); end, 100);
270 272