mod_c2s: Remove connection object from session object when connection disconnected...
[prosody.git] / plugins / mod_compression.lua
index 928560993bcd367d61cdd45c106a69365b08235e..1ec4c85ad1e5b0dd8860272e59f6761aa4f4242e 100644 (file)
@@ -126,7 +126,7 @@ end
 module:hook("stanza/http://jabber.org/protocol/compress:compressed", function(event)
        local session = event.origin;
        
-       if session.type == "s2sout_unauthed" or session.type == "s2sout" then
+       if session.type == "s2sout" then
                session.log("debug", "Activating compression...")
                -- create deflate and inflate streams
                local deflate_stream = get_deflate_stream(session);
@@ -147,10 +147,16 @@ module:hook("stanza/http://jabber.org/protocol/compress:compressed", function(ev
        end
 end);
 
+module:hook("stanza/http://jabber.org/protocol/compress:failure", function(event)
+       local err = event.stanza:get_child();
+       (event.origin.log or module._log)("warn", "Compression setup failed (%s)", err and err.name or "unknown reason");
+       return true;
+end);
+
 module:hook("stanza/http://jabber.org/protocol/compress:compress", function(event)
        local session, stanza = event.origin, event.stanza;
 
-       if session.type == "c2s" or session.type == "s2sin" or session.type == "c2s_unauthed" or session.type == "s2sin_unauthed" then
+       if session.type == "c2s" or session.type == "s2sin" then
                -- fail if we are already compressed
                if session.compressed then
                        local error_st = st.stanza("failure", {xmlns=xmlns_compression_protocol}):tag("setup-failed");