aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2015-09-25 16:51:42 +0100
committerMatthew Wild <mwild1@gmail.com>2015-09-25 16:51:42 +0100
commit51b3e47973a9bd99da761b1d800a74eef45d175b (patch)
treeeea2862632b81d8c25ac5278d21adb835531d35c
parent43333baf051132471dbd2ffb4a168ac5a7f0431a (diff)
parent28d21c104a784b2762f2ca23a421f6865c8ee887 (diff)
downloadprosody-51b3e47973a9bd99da761b1d800a74eef45d175b.tar.gz
prosody-51b3e47973a9bd99da761b1d800a74eef45d175b.zip
Merge 0.9->0.10
-rw-r--r--net/dns.lua4
-rw-r--r--plugins/mod_pep.lua16
2 files changed, 17 insertions, 3 deletions
diff --git a/net/dns.lua b/net/dns.lua
index 80bd895c..d893e38f 100644
--- a/net/dns.lua
+++ b/net/dns.lua
@@ -853,9 +853,7 @@ function resolver:receive(rset) -- - - - - - - - - - - - - - - - - receive
--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 --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua
index a6916d1f..896f3e78 100644
--- a/plugins/mod_pep.lua
+++ b/plugins/mod_pep.lua
@@ -16,10 +16,15 @@ local next = next;
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 @@ module:hook("presence/bare", function(event)
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 @@ module:hook("account-disco-items", function(event)
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);