Comparison

plugins/muc/register.lib.lua @ 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
parent 11286:336cba957c88
child 12028:9ab202e942f5
comparison
equal deleted inserted replaced
11905:bbfa707a4756 11906:ba3344926e18
5 local dataforms = require "util.dataforms"; 5 local dataforms = require "util.dataforms";
6 6
7 local allow_unaffiliated = module:get_option_boolean("allow_unaffiliated_register", false); 7 local allow_unaffiliated = module:get_option_boolean("allow_unaffiliated_register", false);
8 8
9 local enforce_nick = module:get_option_boolean("enforce_registered_nickname", false); 9 local enforce_nick = module:get_option_boolean("enforce_registered_nickname", false);
10
11 -- Whether to include the current registration data as a dataform. Disabled
12 -- by default currently as it hasn't been widely tested with clients.
13 local include_reg_form = module:get_option_boolean("muc_registration_include_form", false);
10 14
11 -- reserved_nicks[nick] = jid 15 -- reserved_nicks[nick] = jid
12 local function get_reserved_nicks(room) 16 local function get_reserved_nicks(room)
13 if room._reserved_nicks then 17 if room._reserved_nicks then
14 return room._reserved_nicks; 18 return room._reserved_nicks;
126 local reply = st.reply(stanza); 130 local reply = st.reply(stanza);
127 local registered_nick = get_registered_nick(room, user_jid); 131 local registered_nick = get_registered_nick(room, user_jid);
128 if stanza.attr.type == "get" then 132 if stanza.attr.type == "get" then
129 reply:query("jabber:iq:register"); 133 reply:query("jabber:iq:register");
130 if registered_nick then 134 if registered_nick then
131 -- I find it strange, but XEP-0045 says not to include
132 -- the current registration data (only the registered name)
133 reply:tag("registered"):up(); 135 reply:tag("registered"):up();
134 reply:tag("username"):text(registered_nick); 136 reply:tag("username"):text(registered_nick):up();
137 if include_reg_form then
138 local aff_data = room:get_affiliation_data(user_jid);
139 if aff_data then
140 reply:add_child(registration_form:form(aff_data, "result"));
141 end
142 end
135 origin.send(reply); 143 origin.send(reply);
136 return true; 144 return true;
137 end 145 end
138 reply:add_child(registration_form:form()); 146 reply:add_child(registration_form:form());
139 else -- type == set -- handle registration form 147 else -- type == set -- handle registration form