Software /
code /
prosody
Changeset
6867:de32d195e932
Merge
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 25 Sep 2015 18:07:33 +0200 |
parents | 6860:153a2e49c4f7 (current diff) 6866:abff7543b79c (diff) |
children | 6868:dcf9ceac9265 6870:d5b416070f70 |
files | |
diffstat | 2 files changed, 17 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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);