Software /
code /
prosody
Comparison
plugins/mod_storage_memory.lua @ 9609:1dfcea523200 0.11
mod_storage_memory: Support the purge driver method
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 07 Nov 2018 20:30:21 +0100 |
parent | 9535:c1befd1c886d |
child | 9783:4c91afc43639 |
child | 9832:96d9c121547b |
comparison
equal
deleted
inserted
replaced
9608:3e44b8dc2cc0 | 9609:1dfcea523200 |
---|---|
195 return setmetatable({ store = memory[store] }, store_mt); | 195 return setmetatable({ store = memory[store] }, store_mt); |
196 end | 196 end |
197 return nil, "unsupported-store"; | 197 return nil, "unsupported-store"; |
198 end | 198 end |
199 | 199 |
200 function driver:purge(user) -- luacheck: ignore 212/self | |
201 for _, store in pairs(memory) do | |
202 store[user] = nil; | |
203 end | |
204 end | |
205 | |
200 if auto_purge_enabled then | 206 if auto_purge_enabled then |
201 module:hook("resource-unbind", function (event) | 207 module:hook("resource-unbind", function (event) |
202 local user_bare_jid = event.session.username.."@"..event.session.host; | 208 local user_bare_jid = event.session.username.."@"..event.session.host; |
203 if not prosody.bare_sessions[user_bare_jid] then -- User went offline | 209 if not prosody.bare_sessions[user_bare_jid] then -- User went offline |
204 module:log("debug", "Clearing store for offline user %s", user_bare_jid); | 210 module:log("debug", "Clearing store for offline user %s", user_bare_jid); |