mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Fix mod_mam compatibility with RSM for other backends
This commit is contained in:
parent
0dfc8ade68
commit
8e27decdfd
@ -663,18 +663,20 @@ filter_by_rsm(_Msgs, #rsm_in{max = Max}) when Max =< 0 ->
|
|||||||
[];
|
[];
|
||||||
filter_by_rsm(Msgs, #rsm_in{max = Max, direction = Direction, id = ID}) ->
|
filter_by_rsm(Msgs, #rsm_in{max = Max, direction = Direction, id = ID}) ->
|
||||||
NewMsgs = case Direction of
|
NewMsgs = case Direction of
|
||||||
aft ->
|
aft when ID /= <<"">> ->
|
||||||
lists:filter(
|
lists:filter(
|
||||||
fun(#archive_msg{id = I}) ->
|
fun(#archive_msg{id = I}) ->
|
||||||
I > ID
|
I > ID
|
||||||
end, Msgs);
|
end, Msgs);
|
||||||
before ->
|
before when ID /= <<"">> ->
|
||||||
lists:foldl(
|
lists:foldl(
|
||||||
fun(#archive_msg{id = I} = Msg, Acc) when I < ID ->
|
fun(#archive_msg{id = I} = Msg, Acc) when I < ID ->
|
||||||
[Msg|Acc];
|
[Msg|Acc];
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, [], Msgs);
|
end, [], Msgs);
|
||||||
|
before when ID == <<"">> ->
|
||||||
|
lists:reverse(Msgs);
|
||||||
_ ->
|
_ ->
|
||||||
Msgs
|
Msgs
|
||||||
end,
|
end,
|
||||||
|
@ -1854,6 +1854,35 @@ mam_query_rsm(Config, NS) ->
|
|||||||
rsm = #rsm_set{count = 10,
|
rsm = #rsm_set{count = 10,
|
||||||
first = undefined,
|
first = undefined,
|
||||||
last = undefined}}]})
|
last = undefined}}]})
|
||||||
|
end,
|
||||||
|
%% Should receive 2 last messages
|
||||||
|
I5 = send(Config,
|
||||||
|
#iq{type = Type,
|
||||||
|
sub_els = [#mam_query{xmlns = NS,
|
||||||
|
rsm = #rsm_set{max = 2,
|
||||||
|
before = none}}]}),
|
||||||
|
maybe_recv_iq_result(NS, I5),
|
||||||
|
lists:foreach(
|
||||||
|
fun(N) ->
|
||||||
|
Text = #text{data = jlib:integer_to_binary(N)},
|
||||||
|
?recv1(#message{to = MyJID,
|
||||||
|
sub_els =
|
||||||
|
[#mam_result{
|
||||||
|
xmlns = NS,
|
||||||
|
sub_els =
|
||||||
|
[#forwarded{
|
||||||
|
delay = #delay{},
|
||||||
|
sub_els =
|
||||||
|
[#message{
|
||||||
|
from = MyJID, to = Peer,
|
||||||
|
body = [Text]}]}]}]})
|
||||||
|
end, lists:seq(4, 5)),
|
||||||
|
if NS == ?NS_MAM_TMP ->
|
||||||
|
?recv1(#iq{type = result, id = I5,
|
||||||
|
sub_els = [#mam_query{xmlns = NS, rsm = #rsm_set{count = 5}}]});
|
||||||
|
true ->
|
||||||
|
?recv1(#message{
|
||||||
|
sub_els = [#mam_fin{rsm = #rsm_set{count = 10}}]})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
client_state_master(Config) ->
|
client_state_master(Config) ->
|
||||||
|
@ -4746,10 +4746,10 @@ encode_rsm_before(Cdata, _xmlns_attrs) ->
|
|||||||
_attrs = _xmlns_attrs,
|
_attrs = _xmlns_attrs,
|
||||||
{xmlel, <<"before">>, _attrs, _els}.
|
{xmlel, <<"before">>, _attrs, _els}.
|
||||||
|
|
||||||
decode_rsm_before_cdata(__TopXMLNS, <<>>) -> undefined;
|
decode_rsm_before_cdata(__TopXMLNS, <<>>) -> none;
|
||||||
decode_rsm_before_cdata(__TopXMLNS, _val) -> _val.
|
decode_rsm_before_cdata(__TopXMLNS, _val) -> _val.
|
||||||
|
|
||||||
encode_rsm_before_cdata(undefined, _acc) -> _acc;
|
encode_rsm_before_cdata(none, _acc) -> _acc;
|
||||||
encode_rsm_before_cdata(_val, _acc) ->
|
encode_rsm_before_cdata(_val, _acc) ->
|
||||||
[{xmlcdata, _val} | _acc].
|
[{xmlcdata, _val} | _acc].
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@
|
|||||||
units = [] :: [binary()]}).
|
units = [] :: [binary()]}).
|
||||||
|
|
||||||
-record(rsm_set, {'after' :: binary(),
|
-record(rsm_set, {'after' :: binary(),
|
||||||
before :: binary(),
|
before :: 'none' | binary(),
|
||||||
count :: non_neg_integer(),
|
count :: non_neg_integer(),
|
||||||
first :: #rsm_first{},
|
first :: #rsm_first{},
|
||||||
index :: non_neg_integer(),
|
index :: non_neg_integer(),
|
||||||
|
@ -2071,6 +2071,7 @@
|
|||||||
-xml(rsm_before,
|
-xml(rsm_before,
|
||||||
#elem{name = <<"before">>,
|
#elem{name = <<"before">>,
|
||||||
xmlns = <<"http://jabber.org/protocol/rsm">>,
|
xmlns = <<"http://jabber.org/protocol/rsm">>,
|
||||||
|
cdata = #cdata{default = none},
|
||||||
result = '$cdata'}).
|
result = '$cdata'}).
|
||||||
|
|
||||||
-xml(rsm_last,
|
-xml(rsm_last,
|
||||||
|
Loading…
Reference in New Issue
Block a user