mod_privacy: Treat stanzas with no 'to' address as going to the user's bare JID ...
authorMatthew Wild <mwild1@gmail.com>
Tue, 29 Jun 2010 19:04:45 +0000 (20:04 +0100)
committerMatthew Wild <mwild1@gmail.com>
Tue, 29 Jun 2010 19:04:45 +0000 (20:04 +0100)
plugins/mod_privacy.lua

index 8dbc2bc48d359e100ce08325076e7a288c20c859..57538ccdfe82a727a71294559bf90f9e11c48345 100644 (file)
@@ -301,7 +301,7 @@ function checkIfNeedToBeBlocked(e, session)
        local origin, stanza = e.origin, e.stanza;
        local privacy_lists = datamanager.load(session.username, session.host, "privacy") or {};
        local bare_jid = session.username.."@"..session.host;
-       local to = stanza.attr.to;
+       local to = stanza.attr.to or bare_jid;
        local from = stanza.attr.from;
        
        local is_to_user = bare_jid == jid_bare(to);
@@ -438,9 +438,7 @@ function preCheckOutgoing(e)
                        e.stanza.attr.from = e.stanza.attr.from .. "/" .. session.resource;
                end
        end
-       if session.username then -- FIXME do properly
-               return checkIfNeedToBeBlocked(e, session);
-       end
+       return checkIfNeedToBeBlocked(e, session);
 end
 
 module:hook("pre-message/full", preCheckOutgoing, 500);