On Thu, 2014-04-10 at 10:55 +0200, Victor Seva wrote:
> So, the presence stanza (from: A@dom to: B@domain) fires
> pre-presence/full (preCheckOutgoing) and later presence/bare
> (preCheckIncoming). The privacy list of the resource with higher
> priority is checked. Then the presence/bare hook from mod_presence gets
> executed, and sends the presence stanza to the sessions with presence of
> that user. All of them, no matter if the resource has a privacyList
> activated.
> 
> So, from our POV this is not the right behaviour, a session has a
> privacyList activated and it has to be honoured.

I've made this changes in order to fix the incoming presence privacyList
check. Now it works as we expected.

What do you think?

Cheers,
Victor
PD: sorry for the dual posting. It seems that I need to wait quite some
time to see that my mail is sent in the mailing list.

-- 
You received this message because you are subscribed to the Google Groups 
"prosody-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to prosody-dev+unsubscr...@googlegroups.com.
To post to this group, send email to prosody-dev@googlegroups.com.
Visit this group at http://groups.google.com/group/prosody-dev.
For more options, visit https://groups.google.com/d/optout.
diff --git a/plugins/mod_privacy.lua b/plugins/mod_privacy.lua
index 31ace9f..614db74 100644
--- a/plugins/mod_privacy.lua
+++ b/plugins/mod_privacy.lua
@@ -414,6 +414,31 @@ function preCheckIncoming(e)
 	end
 end
 
+function preCheckIncomingBare(e)
+	local stanza, origin = e.stanza, e.origin;
+	if stanza.attr.to ~= nil then
+		local node, host, resource = jid_split(stanza.attr.to);
+		if node == nil or host == nil or resource ~= nil then
+			return; -- we only want bare
+		end
+
+		local bare = node.."@"..host;
+		local cloned;
+		if bare_sessions[bare] ~= nil then
+			for resource, session_ in pairs(bare_sessions[bare].sessions) do
+				if checkIfNeedToBeBlocked(e, session_, "in") == nil then
+					module:log("debug", "send message to: %s", tostring(session_.full_jid));
+					cloned = st.clone(stanza);
+					cloned.attr.to = session_.full_jid;
+					origin:send(cloned);
+					module:fire_event("presence/full", {origin=origin, stanza=cloned});
+				end
+			end
+			return true; -- no more
+		end
+	end
+end
+
 function preCheckOutgoing(e)
 	local session = e.origin;
 	if e.stanza.attr.from == nil then
@@ -444,5 +469,5 @@ module:hook("iq/full", preCheckIncoming, 500);
 module:hook("iq/bare", preCheckIncoming, 500);
 module:hook("iq/host", preCheckIncoming, 500);
 module:hook("presence/full", preCheckIncoming, 500);
-module:hook("presence/bare", preCheckIncoming, 500);
+module:hook("presence/bare", preCheckIncomingBare, 500);
 module:hook("presence/host", preCheckIncoming, 500);

Reply via email to