mirror of
https://github.com/processone/ejabberd.git
synced 2024-09-25 14:24:55 +02:00
Replace ?MYLANG with connection's language wherever possible
This commit is contained in:
parent
de49e7631f
commit
e070e6bccb
@ -121,13 +121,14 @@ s2s_out_init(Acc, _Opts) ->
|
|||||||
|
|
||||||
s2s_out_closed(#{server := LServer,
|
s2s_out_closed(#{server := LServer,
|
||||||
remote_server := RServer,
|
remote_server := RServer,
|
||||||
|
lang := Lang,
|
||||||
db_verify := {StreamID, _Key, _Pid}} = State, Reason) ->
|
db_verify := {StreamID, _Key, _Pid}} = State, Reason) ->
|
||||||
%% Outbound s2s verificating connection (created at step 1) is
|
%% Outbound s2s verificating connection (created at step 1) is
|
||||||
%% closed suddenly without receiving the response.
|
%% closed suddenly without receiving the response.
|
||||||
%% Building a response on our own
|
%% Building a response on our own
|
||||||
Response = #db_verify{from = RServer, to = LServer,
|
Response = #db_verify{from = RServer, to = LServer,
|
||||||
id = StreamID, type = error,
|
id = StreamID, type = error,
|
||||||
sub_els = [mk_error(Reason)]},
|
sub_els = [mk_error(Reason, Lang)]},
|
||||||
s2s_out_packet(State, Response);
|
s2s_out_packet(State, Response);
|
||||||
s2s_out_closed(State, _Reason) ->
|
s2s_out_closed(State, _Reason) ->
|
||||||
State.
|
State.
|
||||||
@ -171,7 +172,7 @@ s2s_out_downgraded(#{db_enabled := true,
|
|||||||
s2s_out_downgraded(State, _) ->
|
s2s_out_downgraded(State, _) ->
|
||||||
State.
|
State.
|
||||||
|
|
||||||
s2s_in_packet(#{stream_id := StreamID} = State,
|
s2s_in_packet(#{stream_id := StreamID, lang := Lang} = State,
|
||||||
#db_result{from = From, to = To, key = Key, type = undefined}) ->
|
#db_result{from = From, to = To, key = Key, type = undefined}) ->
|
||||||
%% Received dialback request, section 2.2.1, step 1
|
%% Received dialback request, section 2.2.1, step 1
|
||||||
try
|
try
|
||||||
@ -186,7 +187,7 @@ s2s_in_packet(#{stream_id := StreamID} = State,
|
|||||||
{stop,
|
{stop,
|
||||||
send_db_result(State,
|
send_db_result(State,
|
||||||
#db_verify{from = From, to = To, type = error,
|
#db_verify{from = From, to = To, type = error,
|
||||||
sub_els = [mk_error(Reason)]})}
|
sub_els = [mk_error(Reason, Lang)]})}
|
||||||
end;
|
end;
|
||||||
s2s_in_packet(State, #db_verify{to = To, from = From, key = Key,
|
s2s_in_packet(State, #db_verify{to = To, from = From, key = Key,
|
||||||
id = StreamID, type = undefined}) ->
|
id = StreamID, type = undefined}) ->
|
||||||
@ -204,7 +205,7 @@ s2s_in_packet(State, Pkt) when is_record(Pkt, db_result);
|
|||||||
s2s_in_packet(State, _) ->
|
s2s_in_packet(State, _) ->
|
||||||
State.
|
State.
|
||||||
|
|
||||||
s2s_in_recv(State, El, {error, Why}) ->
|
s2s_in_recv(#{lang := Lang} = State, El, {error, Why}) ->
|
||||||
case xmpp:get_name(El) of
|
case xmpp:get_name(El) of
|
||||||
Tag when Tag == <<"db:result">>;
|
Tag when Tag == <<"db:result">>;
|
||||||
Tag == <<"db:verify">> ->
|
Tag == <<"db:verify">> ->
|
||||||
@ -212,7 +213,7 @@ s2s_in_recv(State, El, {error, Why}) ->
|
|||||||
T when T /= <<"valid">>,
|
T when T /= <<"valid">>,
|
||||||
T /= <<"invalid">>,
|
T /= <<"invalid">>,
|
||||||
T /= <<"error">> ->
|
T /= <<"error">> ->
|
||||||
Err = xmpp:make_error(El, mk_error({codec_error, Why})),
|
Err = xmpp:make_error(El, mk_error({codec_error, Why}, Lang)),
|
||||||
{stop, ejabberd_s2s_in:send(State, Err)};
|
{stop, ejabberd_s2s_in:send(State, Err)};
|
||||||
_ ->
|
_ ->
|
||||||
State
|
State
|
||||||
@ -316,17 +317,17 @@ check_from_to(From, To) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec mk_error(term()) -> stanza_error().
|
-spec mk_error(term(), binary()) -> stanza_error().
|
||||||
mk_error(forbidden) ->
|
mk_error(forbidden, Lang) ->
|
||||||
xmpp:err_forbidden(<<"Access denied by service policy">>, ?MYLANG);
|
xmpp:err_forbidden(<<"Access denied by service policy">>, Lang);
|
||||||
mk_error(host_unknown) ->
|
mk_error(host_unknown, Lang) ->
|
||||||
xmpp:err_not_allowed(<<"Host unknown">>, ?MYLANG);
|
xmpp:err_not_allowed(<<"Host unknown">>, Lang);
|
||||||
mk_error({codec_error, Why}) ->
|
mk_error({codec_error, Why}, Lang) ->
|
||||||
xmpp:err_bad_request(xmpp:io_format_error(Why), ?MYLANG);
|
xmpp:err_bad_request(xmpp:io_format_error(Why), Lang);
|
||||||
mk_error({_Class, _Reason} = Why) ->
|
mk_error({_Class, _Reason} = Why, Lang) ->
|
||||||
Txt = xmpp_stream_out:format_error(Why),
|
Txt = xmpp_stream_out:format_error(Why),
|
||||||
xmpp:err_remote_server_not_found(Txt, ?MYLANG);
|
xmpp:err_remote_server_not_found(Txt, Lang);
|
||||||
mk_error(_) ->
|
mk_error(_, _) ->
|
||||||
xmpp:err_internal_server_error().
|
xmpp:err_internal_server_error().
|
||||||
|
|
||||||
-spec format_error(db_result()) -> binary().
|
-spec format_error(db_result()) -> binary().
|
||||||
|
@ -252,13 +252,13 @@ c2s_handle_info(#{mgmt_ack_timer := TRef, jid := JID, mod := Mod} = State,
|
|||||||
[jid:encode(JID)]),
|
[jid:encode(JID)]),
|
||||||
State1 = Mod:close(State),
|
State1 = Mod:close(State),
|
||||||
{stop, transition_to_pending(State1)};
|
{stop, transition_to_pending(State1)};
|
||||||
c2s_handle_info(#{mgmt_state := pending,
|
c2s_handle_info(#{mgmt_state := pending, lang := Lang,
|
||||||
mgmt_pending_timer := TRef, jid := JID, mod := Mod} = State,
|
mgmt_pending_timer := TRef, jid := JID, mod := Mod} = State,
|
||||||
{timeout, TRef, pending_timeout}) ->
|
{timeout, TRef, pending_timeout}) ->
|
||||||
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
?DEBUG("Timed out waiting for resumption of stream for ~s",
|
||||||
[jid:encode(JID)]),
|
[jid:encode(JID)]),
|
||||||
Txt = <<"Timed out waiting for stream resumption">>,
|
Txt = <<"Timed out waiting for stream resumption">>,
|
||||||
Err = xmpp:serr_connection_timeout(Txt, ?MYLANG),
|
Err = xmpp:serr_connection_timeout(Txt, Lang),
|
||||||
Mod:stop(State#{mgmt_state => timeout,
|
Mod:stop(State#{mgmt_state => timeout,
|
||||||
stop_reason => {stream, {out, Err}}});
|
stop_reason => {stream, {out, Err}}});
|
||||||
c2s_handle_info(#{jid := JID} = State, {_Ref, {resume, OldState}}) ->
|
c2s_handle_info(#{jid := JID} = State, {_Ref, {resume, OldState}}) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user