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:
parent
c7931b4a4f
commit
65e6dfb9dd
@ -756,8 +756,9 @@ 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]) ->
|
||||||
|
try
|
||||||
#xmlel{} = El = xml_stream:parse_element(XML),
|
#xmlel{} = El = xml_stream:parse_element(XML),
|
||||||
Now = usec_to_now(jlib:binary_to_integer(TS)),
|
Now = usec_to_now(jlib:binary_to_integer(TS)),
|
||||||
PeerJid = jid:tolower(jid:from_string(PeerBin)),
|
PeerJid = jid:tolower(jid:from_string(PeerBin)),
|
||||||
@ -766,14 +767,22 @@ select(LServer, #jid{luser = LUser} = JidRequestor,
|
|||||||
null -> chat;
|
null -> chat;
|
||||||
_ -> jlib:binary_to_atom(Kind)
|
_ -> jlib:binary_to_atom(Kind)
|
||||||
end,
|
end,
|
||||||
{TS, jlib:binary_to_integer(TS),
|
[{TS, jlib:binary_to_integer(TS),
|
||||||
msg_to_el(#archive_msg{timestamp = Now,
|
msg_to_el(#archive_msg{timestamp = Now,
|
||||||
packet = El,
|
packet = El,
|
||||||
type = T,
|
type = T,
|
||||||
nick = Nick,
|
nick = Nick,
|
||||||
peer = PeerJid},
|
peer = PeerJid},
|
||||||
MsgType,
|
MsgType,
|
||||||
JidRequestor)}
|
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)};
|
end, Res1), IsComplete, jlib:binary_to_integer(Count)};
|
||||||
_ ->
|
_ ->
|
||||||
{[], false, 0}
|
{[], false, 0}
|
||||||
|
Loading…
Reference in New Issue
Block a user