Advertise in-band registration support.
authorGlenn Maynard <glenn@zewt.org>
Fri, 27 May 2011 16:04:43 +0000 (17:04 +0100)
committerGlenn Maynard <glenn@zewt.org>
Fri, 27 May 2011 16:04:43 +0000 (17:04 +0100)
Implement optional registration support advertisement according to
XEP-0077 sec8:

<features>
    <register xmlns='http://jabber.org/features/iq-register'/>
</features>
---
 plugins/mod_register.lua |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

plugins/mod_register.lua

index 25c09dfa69a2c0013bd5e474a04ccb50348c7913..b4683b58cbe704882f9676027759d2410989b133 100644 (file)
@@ -22,6 +22,18 @@ local compat = module:get_option_boolean("registration_compat", true);
 
 module:add_feature("jabber:iq:register");
 
+local register_stream_feature = st.stanza("register", {xmlns="http://jabber.org/features/iq-register"}):up();
+module:hook("stream-features", function(event)
+        local session, features = event.origin, event.features;
+
+       -- Advertise registration to unauthorized clients only.
+       if module:get_option("allow_registration") == false or session.type ~= "c2s_unauthed" then
+               return
+       end
+
+       features:add_child(register_stream_feature);
+end);
+
 local function handle_registration_stanza(event)
        local session, stanza = event.origin, event.stanza;