# HG changeset patch # User Kim Alvefur # Date 1443197253 -7200 # Node ID de32d195e932d5a5224ecf686e2a71e3180eb59a # Parent 153a2e49c4f7809281db1a032e8a43b4210da297# Parent abff7543b79c6d85d192bd734cc074c46aba306f Merge diff -r 153a2e49c4f7 -r de32d195e932 net/dns.lua --- a/net/dns.lua Fri Sep 25 17:56:21 2015 +0200 +++ b/net/dns.lua Fri Sep 25 18:07:33 2015 +0200 @@ -853,9 +853,7 @@ --self.print(response); for j,rr in pairs(response.answer) do - if rr.name:sub(-#response.question[1].name, -1) == response.question[1].name then - self:remember(rr, response.question[1].type) - end + self:remember(rr, response.question[1].type) end -- retire the query diff -r 153a2e49c4f7 -r de32d195e932 plugins/mod_pep.lua --- a/plugins/mod_pep.lua Fri Sep 25 17:56:21 2015 +0200 +++ b/plugins/mod_pep.lua Fri Sep 25 18:07:33 2015 +0200 @@ -16,10 +16,15 @@ local type = type; local calculate_hash = require "util.caps".calculate_hash; local core_post_stanza = prosody.core_post_stanza; +local bare_sessions = prosody.bare_sessions; +-- Used as canonical 'empty table' local NULL = {}; +-- data[user_bare_jid][node] = item_stanza local data = {}; +--- recipients[user_bare_jid][contact_full_jid][subscribed_node] = true local recipients = {}; +-- hash_map[hash][subscribed_nodes] = true local hash_map = {}; module.save = function() @@ -120,6 +125,9 @@ local t = stanza.attr.type; local self = not stanza.attr.to; + -- Only cache subscriptions if user is online + if not bare_sessions[user] then return; end + if not t then -- available presence if self or subscription_presence(user, stanza.attr.from) then local recipient = stanza.attr.from; @@ -283,3 +291,11 @@ end end end); + +module:hook("resource-unbind", function (event) + local user_bare_jid = event.session.username.."@"..event.session.host; + if not bare_sessions[user_bare_jid] then -- User went offline + -- We don't need this info cached anymore, clear it. + recipients[user_bare_jid] = nil; + end +end);