Skip to content

Commit

Permalink
mod_mam: wipe the cache when the last resource unbinds. (Fixes #47)
Browse files Browse the repository at this point in the history
  • Loading branch information
maranda committed Nov 29, 2013
1 parent 151a74b commit 4581ad0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions plugins/mam/mod_mam.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ local function initialize_session_store(event)
end
end

local function remove_session_store(event)
local user, host = event.session.username, event.session.host;
local bare_jid = jid_join(user, host);
local bare_session = bare_sessions[bare_jid];
if not bare_session then session_stores[bare_jid] = nil; end -- dereference session store.
end

local function save_session_store(event)
local user, host = event.session.username, event.session.host;
local bare_jid = jid_join(user, host);
Expand Down Expand Up @@ -189,6 +196,7 @@ end

module:hook("pre-resource-unbind", save_session_store, 30);
module:hook("resource-bind", initialize_session_store);
module:hook("resource-unbind", remove_session_store, 30);

module:hook("message/bare", process_inbound_messages, 30);
module:hook("pre-message/bare", process_outbound_messages, 30);
Expand Down

0 comments on commit 4581ad0

Please sign in to comment.