From 9fcb81dea99dd7f97ed0c970ed44b23a09153be9 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 19 Jul 2016 21:08:13 +0200 Subject: [PATCH 1/2] mod_mam: Always limit result set page size Limit the number of messages returned for a given MAM request even if the client didn't specify an RSM set (not just if the client specified an RSM set without a limit). This is still not done for MAM v0.2 requests though, as that version of the XEP doesn't require clients to support RSM. --- src/mod_mam.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mod_mam.erl b/src/mod_mam.erl index 10eb098da..f5dc67abc 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -1032,12 +1032,12 @@ filter_by_max(_Msgs, _Junk) -> limit_max(RSM, ?NS_MAM_TMP) -> RSM; % XEP-0313 v0.2 doesn't require clients to support RSM. +limit_max(none, _NS) -> + #rsm_in{max = ?DEF_PAGE_SIZE}; limit_max(#rsm_in{max = Max} = RSM, _NS) when not is_integer(Max) -> RSM#rsm_in{max = ?DEF_PAGE_SIZE}; limit_max(#rsm_in{max = Max} = RSM, _NS) when Max > ?MAX_PAGE_SIZE -> - RSM#rsm_in{max = ?MAX_PAGE_SIZE}; -limit_max(RSM, _NS) -> - RSM. + RSM#rsm_in{max = ?MAX_PAGE_SIZE}. match_interval(Now, Start, End) -> (Now >= Start) and (Now =< End). From 8f8c499cfa78075b8edb41ac3683ce47b54f5f22 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 19 Jul 2016 21:23:30 +0200 Subject: [PATCH 2/2] mod_mam: Fix handling of result set page limit Restore function clause for handling a client-specified result set page limit that doesn't exceed mod_mam's upper threshold. --- src/mod_mam.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mod_mam.erl b/src/mod_mam.erl index f5dc67abc..7e1460695 100644 --- a/src/mod_mam.erl +++ b/src/mod_mam.erl @@ -1037,7 +1037,9 @@ limit_max(none, _NS) -> limit_max(#rsm_in{max = Max} = RSM, _NS) when not is_integer(Max) -> RSM#rsm_in{max = ?DEF_PAGE_SIZE}; limit_max(#rsm_in{max = Max} = RSM, _NS) when Max > ?MAX_PAGE_SIZE -> - RSM#rsm_in{max = ?MAX_PAGE_SIZE}. + RSM#rsm_in{max = ?MAX_PAGE_SIZE}; +limit_max(RSM, _NS) -> + RSM. match_interval(Now, Start, End) -> (Now >= Start) and (Now =< End).