Mercurial > prosody-modules
changeset 2152:bb4a2e4b7ba7
mod_presence_cache: Forget about cached presence when receiving unavailable
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 03 Apr 2016 00:37:11 +0200 |
parents | 96aca307964b |
children | aa24d49c47ef |
files | mod_presence_cache/mod_presence_cache.lua |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_presence_cache/mod_presence_cache.lua Sun Apr 03 00:21:16 2016 +0200 +++ b/mod_presence_cache/mod_presence_cache.lua Sun Apr 03 00:37:11 2016 +0200 @@ -22,6 +22,7 @@ end end +-- used indirectly for the on_evict callback local presence_cache = cache.new(cache_size, on_evict); local function cache_hook(event) @@ -41,8 +42,16 @@ local cache_key = username .. "\0" .. contact_full; local bare_cache_key = username .. "\0" .. contact_bare; + + local jids = bare_cache[bare_cache_key]; + + if typ == "unavailable" then -- remove from cache + presence_cache:set(cache_key, nil); + on_evict(cache_key); + return; + end + local stamp = datetime.datetime(); - local jids = bare_cache[bare_cache_key]; if jids then jids[contact_full] = stamp; else