aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2021-11-15 16:11:03 +0000
committerMatthew Wild <mwild1@gmail.com>2021-11-15 16:11:03 +0000
commit5fa66527d5e2a450dc3d6b0e478f9c4fa190a02c (patch)
tree6b4d688344286a5054817fa0266abc30b58cb12f /plugins
parent38c7c944cad7b5c7d5a0e8419745a077b56289d6 (diff)
downloadprosody-5fa66527d5e2a450dc3d6b0e478f9c4fa190a02c.tar.gz
prosody-5fa66527d5e2a450dc3d6b0e478f9c4fa190a02c.zip
MUC: Add option to include form in registration query
This was originally not done based on my interpretation of XEP-0045. Today's reading, however, revealed that it actually says the result > SHOULD contain **at least** a <username/> element (emphasis mine) I take this to mean that including a form **is** allowed (and I think this is sensible). Tigase already includes the form I believe. I've gated the new behaviour behind a (default off) option, because it hasn't been tested for compatibility with clients. My primary desire for it is in Snikket, where the clients will be tested to ensure compatibility with this. I don't anticipate that (m)any clients would break, so maybe after 0.12 we can experiment with enabling it by default and eventually remove the option.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/muc/register.lib.lua14
1 files changed, 11 insertions, 3 deletions
diff --git a/plugins/muc/register.lib.lua b/plugins/muc/register.lib.lua
index b6559410..c1ff5840 100644
--- a/plugins/muc/register.lib.lua
+++ b/plugins/muc/register.lib.lua
@@ -8,6 +8,10 @@ local allow_unaffiliated = module:get_option_boolean("allow_unaffiliated_registe
local enforce_nick = module:get_option_boolean("enforce_registered_nickname", false);
+-- Whether to include the current registration data as a dataform. Disabled
+-- by default currently as it hasn't been widely tested with clients.
+local include_reg_form = module:get_option_boolean("muc_registration_include_form", false);
+
-- reserved_nicks[nick] = jid
local function get_reserved_nicks(room)
if room._reserved_nicks then
@@ -128,10 +132,14 @@ local function handle_register_iq(room, origin, stanza)
if stanza.attr.type == "get" then
reply:query("jabber:iq:register");
if registered_nick then
- -- I find it strange, but XEP-0045 says not to include
- -- the current registration data (only the registered name)
reply:tag("registered"):up();
- reply:tag("username"):text(registered_nick);
+ reply:tag("username"):text(registered_nick):up();
+ if include_reg_form then
+ local aff_data = room:get_affiliation_data(user_jid);
+ if aff_data then
+ reply:add_child(registration_form:form(aff_data, "result"));
+ end
+ end
origin.send(reply);
return true;
end