aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/mod_mam.erl12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/mod_mam.erl b/src/mod_mam.erl
index a2ff3d4ff..9ea04217f 100644
--- a/src/mod_mam.erl
+++ b/src/mod_mam.erl
@@ -687,11 +687,11 @@ process_iq(LServer, #iq{from = #jid{luser = LUser}, lang = Lang,
#mam_query{rsm = #rsm_set{index = I}} when is_integer(I) ->
Txt = ?T("Unsupported <index/> element"),
xmpp:make_error(IQ, xmpp:err_feature_not_implemented(Txt, Lang));
- #mam_query{rsm = RSM, xmlns = NS} ->
+ #mam_query{rsm = RSM, flippage = FlipPage, xmlns = NS} ->
case parse_query(SubEl, Lang) of
{ok, Query} ->
NewRSM = limit_max(RSM, NS),
- select_and_send(LServer, Query, NewRSM, IQ, MsgType);
+ select_and_send(LServer, Query, NewRSM, FlipPage, IQ, MsgType);
{error, Err} ->
xmpp:make_error(IQ, Err)
end
@@ -1017,7 +1017,7 @@ maybe_activate_mam(LUser, LServer) ->
ok
end.
-select_and_send(LServer, Query, RSM, #iq{from = From, to = To} = IQ, MsgType) ->
+select_and_send(LServer, Query, RSM, FlipPage, #iq{from = From, to = To} = IQ, MsgType) ->
Ret = case MsgType of
chat ->
select(LServer, From, From, Query, RSM, MsgType);
@@ -1027,7 +1027,11 @@ select_and_send(LServer, Query, RSM, #iq{from = From, to = To} = IQ, MsgType) ->
case Ret of
{Msgs, IsComplete, Count} ->
SortedMsgs = lists:keysort(2, Msgs),
- send(SortedMsgs, Count, IsComplete, IQ);
+ SortedMsgs2 = case FlipPage of
+ true -> lists:reverse(SortedMsgs);
+ false -> SortedMsgs
+ end,
+ send(SortedMsgs2, Count, IsComplete, IQ);
{error, _} ->
Txt = ?T("Database failure"),
Err = xmpp:err_internal_server_error(Txt, IQ#iq.lang),