Don't fail on elements decoding
This commit is contained in:
parent
c1439ddd5b
commit
7decd58aaa
|
@ -339,22 +339,29 @@ handle_cast(Request, State) ->
|
||||||
|
|
||||||
-spec handle_info(timeout | _, state()) -> {noreply, state()}.
|
-spec handle_info(timeout | _, state()) -> {noreply, state()}.
|
||||||
|
|
||||||
handle_info({route, #iq{} = Packet}, State) ->
|
handle_info({route, #iq{lang = Lang} = Packet}, State) ->
|
||||||
IQ = xmpp:decode_els(Packet),
|
try xmpp:decode_els(Packet) of
|
||||||
{Reply, NewState} = case process_iq(IQ, State) of
|
IQ ->
|
||||||
R when is_record(R, iq) ->
|
{Reply, NewState} = case process_iq(IQ, State) of
|
||||||
{R, State};
|
R when is_record(R, iq) ->
|
||||||
{R, S} ->
|
{R, State};
|
||||||
{R, S};
|
{R, S} ->
|
||||||
not_request ->
|
{R, S};
|
||||||
{none, State}
|
not_request ->
|
||||||
end,
|
{none, State}
|
||||||
if Reply /= none ->
|
end,
|
||||||
ejabberd_router:route(Reply);
|
if Reply /= none ->
|
||||||
true ->
|
ejabberd_router:route(Reply);
|
||||||
ok
|
true ->
|
||||||
end,
|
ok
|
||||||
{noreply, NewState};
|
end,
|
||||||
|
{noreply, NewState}
|
||||||
|
catch _:{xmpp_codec, Why} ->
|
||||||
|
Txt = xmpp:io_format_error(Why),
|
||||||
|
Err = xmpp:err_bad_request(Txt, Lang),
|
||||||
|
ejabberd_router:route_error(Packet, Err),
|
||||||
|
{noreply, State}
|
||||||
|
end;
|
||||||
handle_info({slot_timed_out, Slot}, State) ->
|
handle_info({slot_timed_out, Slot}, State) ->
|
||||||
NewState = del_slot(Slot, State),
|
NewState = del_slot(Slot, State),
|
||||||
{noreply, NewState};
|
{noreply, NewState};
|
||||||
|
@ -517,6 +524,8 @@ process_iq(#iq{type = get, lang = Lang, sub_els = [#disco_info{}]} = IQ,
|
||||||
AddInfo = ejabberd_hooks:run_fold(disco_info, ServerHost, [],
|
AddInfo = ejabberd_hooks:run_fold(disco_info, ServerHost, [],
|
||||||
[ServerHost, ?MODULE, <<"">>, <<"">>]),
|
[ServerHost, ?MODULE, <<"">>, <<"">>]),
|
||||||
xmpp:make_iq_result(IQ, iq_disco_info(ServerHost, Lang, Name, AddInfo));
|
xmpp:make_iq_result(IQ, iq_disco_info(ServerHost, Lang, Name, AddInfo));
|
||||||
|
process_iq(#iq{type = get, sub_els = [#disco_items{}]} = IQ, _State) ->
|
||||||
|
xmpp:make_iq_result(IQ, #disco_items{});
|
||||||
process_iq(#iq{type = get, lang = Lang, from = From,
|
process_iq(#iq{type = get, lang = Lang, from = From,
|
||||||
sub_els = [#upload_request{filename = File,
|
sub_els = [#upload_request{filename = File,
|
||||||
size = Size,
|
size = Size,
|
||||||
|
@ -546,8 +555,9 @@ process_iq(#iq{type = get, lang = Lang, from = From,
|
||||||
Txt = <<"Denied by ACL">>,
|
Txt = <<"Denied by ACL">>,
|
||||||
xmpp:make_error(IQ, xmpp:err_forbidden(Txt, Lang))
|
xmpp:make_error(IQ, xmpp:err_forbidden(Txt, Lang))
|
||||||
end;
|
end;
|
||||||
process_iq(#iq{type = T} = IQ, _State) when T == get; T == set ->
|
process_iq(#iq{type = T, lang = Lang} = IQ, _State) when T == get; T == set ->
|
||||||
xmpp:make_error(IQ, xmpp:err_not_allowed());
|
Txt = <<"No module is handling this query">>,
|
||||||
|
xmpp:make_error(IQ, xmpp:err_service_unavailable(Txt, Lang));
|
||||||
process_iq(#iq{}, _State) ->
|
process_iq(#iq{}, _State) ->
|
||||||
not_request.
|
not_request.
|
||||||
|
|
||||||
|
@ -716,7 +726,8 @@ iq_disco_info(Host, Lang, Name, AddInfo) ->
|
||||||
#disco_info{identities = [#identity{category = <<"store">>,
|
#disco_info{identities = [#identity{category = <<"store">>,
|
||||||
type = <<"file">>,
|
type = <<"file">>,
|
||||||
name = translate:translate(Lang, Name)}],
|
name = translate:translate(Lang, Name)}],
|
||||||
features = [?NS_HTTP_UPLOAD, ?NS_HTTP_UPLOAD_OLD],
|
features = [?NS_HTTP_UPLOAD, ?NS_HTTP_UPLOAD_OLD,
|
||||||
|
?NS_DISCO_INFO, ?NS_DISCO_ITEMS],
|
||||||
xdata = Form}.
|
xdata = Form}.
|
||||||
|
|
||||||
%% HTTP request handling.
|
%% HTTP request handling.
|
||||||
|
|
Loading…
Reference in New Issue