Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2016-01-14 04:27:02 +0300
committerHolger Weiss <holger@zedat.fu-berlin.de>2016-01-14 04:27:02 +0300
commitdb04cdf2ca7eea42024b4cc7bae5e9bea4f4e5e8 (patch)
tree7badd0e639d35a6bae66b4984d443b6c07b88684 /src/mod_mam.erl
parent58c8fc57709b91960d2cce5d67baf674b27b4a3d (diff)
mod_mam: Sort messages returned by Mnesia
Sort the messages retrieved from an Mnesia archive before selecting the subset limited by the <max/> value. This makes sure the desired subset of messages is sent to the client.
Diffstat (limited to 'src/mod_mam.erl')
-rw-r--r--src/mod_mam.erl3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/mod_mam.erl b/src/mod_mam.erl
index 6bc8c0c01..c20a941df 100644
--- a/src/mod_mam.erl
+++ b/src/mod_mam.erl
@@ -898,7 +898,8 @@ select(_LServer, #jid{luser = LUser, lserver = LServer} = JidRequestor,
Start, End, With, RSM, MsgType, mnesia) ->
MS = make_matchspec(LUser, LServer, Start, End, With),
Msgs = mnesia:dirty_select(archive_msg, MS),
- {FilteredMsgs, IsComplete} = filter_by_rsm(Msgs, RSM),
+ SortedMsgs = lists:keysort(#archive_msg.timestamp, Msgs),
+ {FilteredMsgs, IsComplete} = filter_by_rsm(SortedMsgs, RSM),
Count = length(Msgs),
{lists:map(
fun(Msg) ->