25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

mod_stream_mgmt: Add descriptive text to errors

Closes #2485.
This commit is contained in:
Holger Weiss 2018-07-10 00:46:48 +02:00
parent 8b9166d067
commit b915469f5e

View File

@ -337,7 +337,7 @@ queue_find(Pred, Queue) ->
%%% Internal functions
%%%===================================================================
-spec negotiate_stream_mgmt(xmpp_element(), state()) -> state().
negotiate_stream_mgmt(Pkt, State) ->
negotiate_stream_mgmt(Pkt, #{lang := Lang} = State) ->
Xmlns = xmpp:get_ns(Pkt),
case Pkt of
#sm_enable{} ->
@ -345,7 +345,10 @@ negotiate_stream_mgmt(Pkt, State) ->
_ when is_record(Pkt, sm_a);
is_record(Pkt, sm_r);
is_record(Pkt, sm_resume) ->
Err = #sm_failed{reason = 'unexpected-request', xmlns = Xmlns},
Txt = <<"Stream management is not enabled">>,
Err = #sm_failed{reason = 'unexpected-request',
text = xmpp:mk_text(Txt, Lang),
xmlns = Xmlns},
send(State, Err);
_ ->
Err = #sm_failed{reason = 'bad-request', xmlns = Xmlns},
@ -363,7 +366,9 @@ perform_stream_mgmt(Pkt, #{mgmt_xmlns := Xmlns, lang := Lang} = State) ->
handle_a(State, Pkt);
_ when is_record(Pkt, sm_enable);
is_record(Pkt, sm_resume) ->
Txt = <<"Stream management is already enabled">>,
send(State, #sm_failed{reason = 'unexpected-request',
text = xmpp:mk_text(Txt, Lang),
xmlns = Xmlns});
_ ->
send(State, #sm_failed{reason = 'bad-request',