]> granicus.if.org Git - ejabberd/commitdiff
mod_push_keepalive: Preserve timeout on resumption
authorHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 5 Mar 2018 00:10:12 +0000 (01:10 +0100)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Mon, 5 Mar 2018 00:10:12 +0000 (01:10 +0100)
Don't forget to carry over the original XEP-0198 resumption timeout
value while resuming.

src/mod_push_keepalive.erl

index 35932a81500722eacafe65e522f05ce5398e4dfd..750427ee186ce5e9c751242229ed8c065698da73 100644 (file)
@@ -156,9 +156,15 @@ c2s_session_resumed(State) ->
 -spec c2s_copy_session(c2s_state(), c2s_state()) -> c2s_state().
 c2s_copy_session(State, #{push_enabled := true,
                          push_resume_timeout := ResumeTimeout,
-                         push_wake_on_timeout := WakeOnTimeout}) ->
-    State#{push_resume_timeout => ResumeTimeout,
-          push_wake_on_timeout => WakeOnTimeout};
+                         push_wake_on_timeout := WakeOnTimeout} = OldState) ->
+    State1 = case maps:find(push_resume_timeout_orig, OldState) of
+                {ok, Val} ->
+                    State#{push_resume_timeout_orig => Val};
+                error ->
+                    State
+            end,
+    State1#{push_resume_timeout => ResumeTimeout,
+           push_wake_on_timeout => WakeOnTimeout};
 c2s_copy_session(State, _) ->
     State.