25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

Resending unacked stanzas should send even archived msgs if mod_offline is enabled

Messages that are received when no c2s is active will be stored in offline,
even when mam archived them, so i don't think we should be doing something
different in this case.
This commit is contained in:
Paweł Chmielowski 2020-04-16 13:04:12 +02:00
parent cd0b65f4d5
commit 37226dd41f

View File

@ -605,6 +605,7 @@ route_unacked_stanzas(#{mgmt_state := MgmtState,
end, end,
?DEBUG("Re-routing ~B unacknowledged stanza(s) to ~ts", ?DEBUG("Re-routing ~B unacknowledged stanza(s) to ~ts",
[p1_queue:len(Queue), jid:encode(JID)]), [p1_queue:len(Queue), jid:encode(JID)]),
ModOfflineEnabled = gen_mod:is_loaded(LServer, mod_offline),
p1_queue:foreach( p1_queue:foreach(
fun({_, _Time, #presence{from = From}}) -> fun({_, _Time, #presence{from = From}}) ->
?DEBUG("Dropping presence stanza from ~ts", [jid:encode(From)]); ?DEBUG("Dropping presence stanza from ~ts", [jid:encode(From)]);
@ -621,20 +622,21 @@ route_unacked_stanzas(#{mgmt_state := MgmtState,
?DEBUG("Dropping forwarded message stanza from ~ts", ?DEBUG("Dropping forwarded message stanza from ~ts",
[jid:encode(From)]); [jid:encode(From)]);
({_, Time, #message{} = Msg}) -> ({_, Time, #message{} = Msg}) ->
case ejabberd_hooks:run_fold(message_is_archived, case {ModOfflineEnabled, ResendOnTimeout,
LServer, false, xmpp:get_meta(Msg, mam_archived, false)} of
[State, Msg]) of Val when Val == {true, true, false};
true -> Val == {true, true, true};
?DEBUG("Dropping archived message stanza from ~ts", Val == {false, true, false} ->
[jid:encode(xmpp:get_from(Msg))]); NewEl = add_resent_delay_info(State, Msg, Time),
false when ResendOnTimeout -> ejabberd_router:route(NewEl);
NewEl = add_resent_delay_info(State, Msg, Time), {_, _, true} ->
ejabberd_router:route(NewEl); ?DEBUG("Dropping archived message stanza from ~s",
false -> [jid:encode(xmpp:get_from(Msg))]);
Txt = ?T("User session terminated"), _ ->
ejabberd_router:route_error( Txt = ?T("User session terminated"),
Msg, xmpp:err_service_unavailable(Txt, Lang)) ejabberd_router:route_error(
end; Msg, xmpp:err_service_unavailable(Txt, Lang))
end;
({_, _Time, El}) -> ({_, _Time, El}) ->
%% Raw element of type 'error' resulting from a validation error %% Raw element of type 'error' resulting from a validation error
%% We cannot pass it to the router, it will generate an error %% We cannot pass it to the router, it will generate an error