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

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.
This commit is contained in:
Holger Weiss 2016-01-14 02:27:02 +01:00
parent 58c8fc5770
commit db04cdf2ca

View File

@ -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) ->