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:
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>2015-07-09 13:01:37 +0300
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>2015-07-10 13:59:33 +0300
commit8e27decdfd9f91bc9ae2c01bc4df2ca7254d8242 (patch)
tree758b19fd3eec089d3eeb10fa8b8e882ccf987b02 /src/mod_mam.erl
parent0dfc8ade6837f8267e1f3150db629509f5c066fe (diff)
Fix mod_mam compatibility with RSM for other backends
Diffstat (limited to 'src/mod_mam.erl')
-rw-r--r--src/mod_mam.erl32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/mod_mam.erl b/src/mod_mam.erl
index cd869c9d8..4e58f9ffb 100644
--- a/src/mod_mam.erl
+++ b/src/mod_mam.erl
@@ -663,21 +663,23 @@ filter_by_rsm(_Msgs, #rsm_in{max = Max}) when Max =< 0 ->
[];
filter_by_rsm(Msgs, #rsm_in{max = Max, direction = Direction, id = ID}) ->
NewMsgs = case Direction of
- aft ->
- lists:filter(
- fun(#archive_msg{id = I}) ->
- I > ID
- end, Msgs);
- before ->
- lists:foldl(
- fun(#archive_msg{id = I} = Msg, Acc) when I < ID ->
- [Msg|Acc];
- (_, Acc) ->
- Acc
- end, [], Msgs);
- _ ->
- Msgs
- end,
+ aft when ID /= <<"">> ->
+ lists:filter(
+ fun(#archive_msg{id = I}) ->
+ I > ID
+ end, Msgs);
+ before when ID /= <<"">> ->
+ lists:foldl(
+ fun(#archive_msg{id = I} = Msg, Acc) when I < ID ->
+ [Msg|Acc];
+ (_, Acc) ->
+ Acc
+ end, [], Msgs);
+ before when ID == <<"">> ->
+ lists:reverse(Msgs);
+ _ ->
+ Msgs
+ end,
filter_by_max(NewMsgs, Max).
filter_by_max(Msgs, undefined) ->