aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2022-11-13 19:44:53 +0100
committerKim Alvefur <zash@zash.se>2022-11-13 19:44:53 +0100
commit8bb22ccfedb17d8cc2e7c6916ab84c58e3c98ed6 (patch)
tree8f335e876d6a54e9fec3e9ec6ba7969d3405c097 /plugins
parent080d7974bf0c1da8a1c0578d67c3172facc9d719 (diff)
downloadprosody-8bb22ccfedb17d8cc2e7c6916ab84c58e3c98ed6.tar.gz
prosody-8bb22ccfedb17d8cc2e7c6916ab84c58e3c98ed6.zip
mod_smacks: Factor out resumption token table key generation
So that happens in a single place, where it can be changed easier.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_smacks.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/plugins/mod_smacks.lua b/plugins/mod_smacks.lua
index ad1b8dd6..d5b3e847 100644
--- a/plugins/mod_smacks.lua
+++ b/plugins/mod_smacks.lua
@@ -84,19 +84,23 @@ local all_old_sessions = module:open_store("smacks_h");
local old_session_registry = module:open_store("smacks_h", "map");
local session_registry = module:shared "/*/smacks/resumption-tokens"; -- > user@host/resumption-token --> resource
+local function registry_key(session, id)
+ return jid.join(session.username, session.host, id or session.resumption_token);
+end
+
local function track_session(session, id)
- session_registry[jid.join(session.username, session.host, id or session.resumption_token)] = session;
+ session_registry[registry_key(session, id)] = session;
session.resumption_token = id;
end
local function save_old_session(session)
- session_registry[jid.join(session.username, session.host, session.resumption_token)] = nil;
+ session_registry[registry_key(session)] = nil;
return old_session_registry:set(session.username, session.resumption_token,
{ h = session.handled_stanza_count; t = os.time() })
end
local function clear_old_session(session, id)
- session_registry[jid.join(session.username, session.host, id or session.resumption_token)] = nil;
+ session_registry[registry_key(session, id)] = nil;
return old_session_registry:set(session.username, id or session.resumption_token, nil)
end
@@ -570,7 +574,7 @@ function do_resume(session, stanza)
end
local id = stanza.attr.previd;
- local original_session = session_registry[jid.join(session.username, session.host, id)];
+ local original_session = session_registry[registry_key(session, id)];
if not original_session then
local old_session = old_session_registry:get(session.username, id);
if old_session then