Changeset

6866:abff7543b79c

Merge 0.9->0.10
author Matthew Wild <mwild1@gmail.com>
date Fri, 25 Sep 2015 16:51:42 +0100
parents 6858:d8f8c0b2fda8 (current diff) 6865:20b0f0b48655 (diff)
children 6867:de32d195e932
files net/dns.lua plugins/mod_pep.lua
diffstat 2 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/net/dns.lua	Fri Sep 25 17:43:21 2015 +0200
+++ b/net/dns.lua	Fri Sep 25 16:51:42 2015 +0100
@@ -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
--- a/plugins/mod_pep.lua	Fri Sep 25 17:43:21 2015 +0200
+++ b/plugins/mod_pep.lua	Fri Sep 25 16:51:42 2015 +0100
@@ -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);