25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Include <x/> tag in presence errors related to nick change

Refer to example 52 and example 53 of XEP-0045 for details.
Thanks to Daniel Gultsch for spotting this.
This commit is contained in:
Evgeniy Khramtsov 2017-12-09 23:13:20 +03:00
parent 614bd9dd72
commit ae66c17ec0

View File

@ -1011,22 +1011,25 @@ do_process_presence(Nick, #presence{from = From, type = available, lang = Lang}
{(StateData#state.config)#config.allow_visitor_nickchange,
is_visitor(From, StateData)}} of
{_, _, {false, true}} ->
Packet1 = Packet#presence{sub_els = [#muc{}]},
ErrText = <<"Visitors are not allowed to change their "
"nicknames in this room">>,
Err = xmpp:err_not_allowed(ErrText, Lang),
ejabberd_router:route_error(Packet, Err),
ejabberd_router:route_error(Packet1, Err),
StateData;
{true, _, _} ->
Packet1 = Packet#presence{sub_els = [#muc{}]},
ErrText = <<"That nickname is already in use by another "
"occupant">>,
Err = xmpp:err_conflict(ErrText, Lang),
ejabberd_router:route_error(Packet, Err),
ejabberd_router:route_error(Packet1, Err),
StateData;
{_, false, _} ->
Packet1 = Packet#presence{sub_els = [#muc{}]},
ErrText = <<"That nickname is registered by another "
"person">>,
Err = xmpp:err_conflict(ErrText, Lang),
ejabberd_router:route_error(Packet, Err),
ejabberd_router:route_error(Packet1, Err),
StateData;
_ ->
change_nick(From, Nick, StateData)