diff mod_sasl2/mod_sasl2.lua @ 5049:e89aad13a52a

mod_sasl2: Further break up success handling, into pre/post stream:features This allows us to enable mod_smacks after sending success, but before sending stream:features. Previously, the features were being calculated before SM was finalized on the session. We can't finalize SM before sending <success> because it may generate stanzas.
author Matthew Wild <mwild1@gmail.com>
date Thu, 22 Sep 2022 18:25:44 +0100
parents 3697d19d5fd9
children 53145c6b6b0b
line wrap: on
line diff
--- a/mod_sasl2/mod_sasl2.lua	Thu Sep 22 16:48:05 2022 +0100
+++ b/mod_sasl2/mod_sasl2.lua	Thu Sep 22 18:25:44 2022 +0100
@@ -158,10 +158,14 @@
 	local session = event.session
 	event.success:text_tag("authorization-identifier", jid_join(session.username, session.host, session.resource));
 	session.send(event.success);
+end, -1000);
+
+module:hook("sasl2/c2s/success", function (event)
+	local session = event.session;
 	local features = st.stanza("stream:features");
 	module:fire_event("stream-features", { origin = session, features = features });
 	session.send(features);
-end, -1000);
+end, -1500);
 
 -- The gap here is to allow modules to do stuff to the stream after the stanza
 -- is sent, but before we proceed with anything else. This is expected to be