Changeset

11906:ba3344926e18

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.
author Matthew Wild <mwild1@gmail.com>
date Mon, 15 Nov 2021 16:11:03 +0000
parents 11905:bbfa707a4756
children 11907:0dc2c3530d64
files plugins/muc/register.lib.lua
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/register.lib.lua	Mon Nov 15 13:31:06 2021 +0100
+++ b/plugins/muc/register.lib.lua	Mon Nov 15 16:11:03 2021 +0000
@@ -8,6 +8,10 @@
 
 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 @@
 	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