mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-02 21:17:12 +02:00
Sort messages by stanza_id when using mam storage in mod_offline
This commit is contained in:
parent
faf9b20ac0
commit
aaf674160b
|
@ -811,12 +811,27 @@ read_mam_messages(LUser, LServer, ReadMsgs) ->
|
||||||
end,
|
end,
|
||||||
AllMsgs2 = lists:sort(
|
AllMsgs2 = lists:sort(
|
||||||
fun(A, B) ->
|
fun(A, B) ->
|
||||||
case {xmpp:get_subtag(A, #delay{}), xmpp:get_subtag(B, #delay{})} of
|
DA = case xmpp:get_subtag(A, #stanza_id{}) of
|
||||||
{#delay{stamp = TA}, #delay{stamp = TB}} ->
|
#stanza_id{id = IDA} ->
|
||||||
TA < TB;
|
IDA;
|
||||||
_ ->
|
_ -> case xmpp:get_subtag(A, #delay{}) of
|
||||||
true
|
#delay{stamp = STA} ->
|
||||||
end
|
integer_to_binary(misc:now_to_usec(STA));
|
||||||
|
_ ->
|
||||||
|
<<"unknown">>
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
DB = case xmpp:get_subtag(B, #stanza_id{}) of
|
||||||
|
#stanza_id{id = IDB} ->
|
||||||
|
IDB;
|
||||||
|
_ -> case xmpp:get_subtag(B, #delay{}) of
|
||||||
|
#delay{stamp = STB} ->
|
||||||
|
integer_to_binary(misc:now_to_usec(STB));
|
||||||
|
_ ->
|
||||||
|
<<"unknown">>
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
DA < DB
|
||||||
end, AllMsgs),
|
end, AllMsgs),
|
||||||
{AllMsgs3, _} = lists:mapfoldl(
|
{AllMsgs3, _} = lists:mapfoldl(
|
||||||
fun(Msg, Counter) ->
|
fun(Msg, Counter) ->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user