# HG changeset patch # User Kim Alvefur # Date 1459636631 -7200 # Node ID bb4a2e4b7ba7309e3c42160fc56e4bde3a575ce7 # Parent 96aca307964b0beab57ba28719b7d49b509970e8 mod_presence_cache: Forget about cached presence when receiving unavailable diff -r 96aca307964b -r bb4a2e4b7ba7 mod_presence_cache/mod_presence_cache.lua --- 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