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

Do not fail on incorrect data coming from SQL (898)

This commit is contained in:
Evgeniy Khramtsov 2016-01-11 14:35:11 +03:00
parent c7931b4a4f
commit 65e6dfb9dd

View File

@ -756,25 +756,34 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
true -> true ->
{Res, true} {Res, true}
end, end,
{lists:map( {lists:flatmap(
fun([TS, XML, PeerBin, Kind, Nick]) -> fun([TS, XML, PeerBin, Kind, Nick]) ->
#xmlel{} = El = xml_stream:parse_element(XML), try
Now = usec_to_now(jlib:binary_to_integer(TS)), #xmlel{} = El = xml_stream:parse_element(XML),
PeerJid = jid:tolower(jid:from_string(PeerBin)), Now = usec_to_now(jlib:binary_to_integer(TS)),
T = case Kind of PeerJid = jid:tolower(jid:from_string(PeerBin)),
<<"">> -> chat; T = case Kind of
null -> chat; <<"">> -> chat;
_ -> jlib:binary_to_atom(Kind) null -> chat;
end, _ -> jlib:binary_to_atom(Kind)
{TS, jlib:binary_to_integer(TS), end,
msg_to_el(#archive_msg{timestamp = Now, [{TS, jlib:binary_to_integer(TS),
packet = El, msg_to_el(#archive_msg{timestamp = Now,
type = T, packet = El,
nick = Nick, type = T,
peer = PeerJid}, nick = Nick,
MsgType, peer = PeerJid},
JidRequestor)} MsgType,
end, Res1), IsComplete, jlib:binary_to_integer(Count)}; JidRequestor)}]
catch _:Err ->
?ERROR_MSG("failed to parse data from SQL: ~p. "
"The data was: "
"timestamp = ~s, xml = ~s, "
"peer = ~s, kind = ~s, nick = ~s",
[Err, TS, XML, PeerBin, Kind, Nick]),
[]
end
end, Res1), IsComplete, jlib:binary_to_integer(Count)};
_ -> _ ->
{[], false, 0} {[], false, 0}
end. end.