Software /
code /
prosody
Changeset
9298:2d71040a959f
MUC: If a user with an existing affiliation registers, preserve that affiliation (thanks jc)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Thu, 13 Sep 2018 14:46:24 +0100 |
parents | 9297:8680a874f483 |
children | 9299:2466b533f63d |
files | plugins/muc/register.lib.lua spec/scansion/muc_register.scs |
diffstat | 2 files changed, 66 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/muc/register.lib.lua Wed Sep 12 14:59:52 2018 +0100 +++ b/plugins/muc/register.lib.lua Thu Sep 13 14:46:24 2018 +0100 @@ -174,7 +174,7 @@ -- Checks passed, save the registration if registered_nick ~= desired_nick then local registration_data = { reserved_nickname = desired_nick }; - local ok, err_type, err_condition = room:set_affiliation(true, user_jid, "member", nil, registration_data); + local ok, err_type, err_condition = room:set_affiliation(true, user_jid, affiliation or "member", nil, registration_data); if not ok then origin.send(st.error_reply(stanza, err_type, err_condition)); return true;
--- a/spec/scansion/muc_register.scs Wed Sep 12 14:59:52 2018 +0100 +++ b/spec/scansion/muc_register.scs Thu Sep 13 14:46:24 2018 +0100 @@ -286,3 +286,68 @@ Romeo receives: <presence from="room@conference.localhost/Juliet" /> +# Romeo updates his own registration + +Romeo sends: + <iq id='jw81b36f' to='room@conference.localhost' type='get'> + <query xmlns='jabber:iq:register'/> + </iq> + +Romeo receives: + <iq type='result' from='room@conference.localhost' id='jw81b36f'> + <query xmlns='jabber:iq:register'> + <x type='form' xmlns='jabber:x:data'> + <field type='hidden' var='FORM_TYPE'> + <value>http://jabber.org/protocol/muc#register</value> + </field> + <field type='text-single' label='Nickname' var='muc#register_roomnick'/> + </x> + </query> + </iq> + +Romeo sends: + <iq id='nv71va54' to='room@conference.localhost' type='set'> + <query xmlns='jabber:iq:register'> + <x xmlns='jabber:x:data' type='submit'> + <field var='FORM_TYPE'> + <value>http://jabber.org/protocol/muc#register</value> + </field> + <field var='muc#register_roomnick'> + <value>Romeo</value> + </field> + </x> + </query> + </iq> + +Romeo receives: + <presence from='room@conference.localhost/Romeo'> + <x xmlns='http://jabber.org/protocol/muc#user'> + <item affiliation='owner' jid="${Romeo's full JID}" role='moderator'/> + <status code='110'/> + </x> + </presence> + +Romeo receives: + <iq type='result' from='room@conference.localhost' id='nv71va54'/> + +Juliet receives: + <presence from='room@conference.localhost/Romeo'> + <x xmlns='http://jabber.org/protocol/muc#user'> + <item role='moderator' xmlns='http://jabber.org/protocol/muc#user' affiliation='owner'/> + </x> + </presence> + +# Romeo discovers his reserved nick + +Romeo sends: + <iq id='getnick1' to='room@conference.localhost' type='get'> + <query xmlns='http://jabber.org/protocol/disco#info' node='x-roomuser-item'/> + </iq> + +Romeo receives: + <iq type='result' from='room@conference.localhost' id='getnick1'> + <query xmlns='http://jabber.org/protocol/disco#info'> + <identity category='conference' name='Romeo' type='text'/> + </query> + </iq> +