From 0a9212583dd59535432a10e88aeaec097ae1bd0a Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Tue, 16 Sep 2014 22:42:34 +0200 Subject: XEP-0198: Support "resend_on_timeout: if_offline" If "resend_on_timeout" is set to "if_offline", resend unacknowledged stanzas only if no other resource is online when the session times out. In other words, allow for sending them to offline storage, but nowhere else. --- src/ejabberd_c2s.erl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index cb6f9e6d8..d0dfd2553 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -316,7 +316,11 @@ init([{SockMod, Socket}, Opts]) -> Timeout when is_integer(Timeout), Timeout >= 0 -> Timeout; _ -> 300 end, - ResendOnTimeout = proplists:get_bool(resend_on_timeout, Opts), + ResendOnTimeout = case proplists:get_value(resend_on_timeout, Opts) of + Resend when is_boolean(Resend) -> Resend; + if_offline -> if_offline; + _ -> false + end, IP = peerip(SockMod, Socket), Socket1 = if TLSEnabled andalso SockMod /= ejabberd_frontend_socket -> @@ -2879,7 +2883,15 @@ handle_unacked_stanzas(_StateData, _F) -> handle_unacked_stanzas(StateData) when StateData#state.mgmt_state == active; StateData#state.mgmt_state == pending -> - ReRoute = case StateData#state.mgmt_resend of + ResendOnTimeout = + case StateData#state.mgmt_resend of + Resend when is_boolean(Resend) -> + Resend; + if_offline -> + ejabberd_sm:get_user_resources(StateData#state.user, + StateData#state.server) == [] + end, + ReRoute = case ResendOnTimeout of true -> fun ejabberd_router:route/3; false -> -- cgit v1.2.3