aboutsummaryrefslogtreecommitdiff
path: root/src/mod_mam_mnesia.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mod_mam_mnesia.erl')
-rw-r--r--src/mod_mam_mnesia.erl15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mod_mam_mnesia.erl b/src/mod_mam_mnesia.erl
index 6b296f772..f498bc3c7 100644
--- a/src/mod_mam_mnesia.erl
+++ b/src/mod_mam_mnesia.erl
@@ -160,12 +160,17 @@ select(_LServer, JidRequestor,
SortedMsgs = lists:keysort(#archive_msg.timestamp, Msgs),
{FilteredMsgs, IsComplete} = filter_by_rsm(SortedMsgs, RSM),
Count = length(Msgs),
- Result = {lists:map(
+ Result = {lists:flatmap(
fun(Msg) ->
- {Msg#archive_msg.id,
- binary_to_integer(Msg#archive_msg.id),
- mod_mam:msg_to_el(Msg, MsgType, JidRequestor,
- JidArchive)}
+ case mod_mam:msg_to_el(
+ Msg, MsgType, JidRequestor, JidArchive) of
+ {ok, El} ->
+ [{Msg#archive_msg.id,
+ binary_to_integer(Msg#archive_msg.id),
+ El}];
+ {error, _} ->
+ []
+ end
end, FilteredMsgs), IsComplete, Count},
erlang:garbage_collect(),
Result.