aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-09-16 22:42:34 +0200
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-09-16 22:42:34 +0200
commit0a9212583dd59535432a10e88aeaec097ae1bd0a (patch)
treeebb48393b2025f03c61286874203755d6d1f6c59 /src
parentMerge pull request #299 from sjmackenzie/processone (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/ejabberd_c2s.erl16
1 files changed, 14 insertions, 2 deletions
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 ->