mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
mod_push: Keep push session ID on session resume
Don't forget the push session ID if the client resumes a stream management session. This makes sure no push notifications are generated for a connected client with a resumed stream management session. Thanks to Thilo Molitor for spotting the issue.
This commit is contained in:
parent
c148ab4430
commit
b5a76fb4de
@ -34,8 +34,8 @@
|
||||
-export([mod_doc/0]).
|
||||
%% ejabberd_hooks callbacks.
|
||||
-export([disco_sm_features/5, c2s_session_pending/1, c2s_copy_session/2,
|
||||
c2s_handle_cast/2, c2s_stanza/3, mam_message/7, offline_message/1,
|
||||
remove_user/2]).
|
||||
c2s_session_resumed/1, c2s_handle_cast/2, c2s_stanza/3, mam_message/7,
|
||||
offline_message/1, remove_user/2]).
|
||||
|
||||
%% gen_iq_handler callback.
|
||||
-export([process_iq/1]).
|
||||
@ -259,6 +259,8 @@ register_hooks(Host) ->
|
||||
c2s_session_pending, 50),
|
||||
ejabberd_hooks:add(c2s_copy_session, Host, ?MODULE,
|
||||
c2s_copy_session, 50),
|
||||
ejabberd_hooks:add(c2s_session_resumed, Host, ?MODULE,
|
||||
c2s_session_resumed, 50),
|
||||
ejabberd_hooks:add(c2s_handle_cast, Host, ?MODULE,
|
||||
c2s_handle_cast, 50),
|
||||
ejabberd_hooks:add(c2s_handle_send, Host, ?MODULE,
|
||||
@ -278,6 +280,8 @@ unregister_hooks(Host) ->
|
||||
c2s_session_pending, 50),
|
||||
ejabberd_hooks:delete(c2s_copy_session, Host, ?MODULE,
|
||||
c2s_copy_session, 50),
|
||||
ejabberd_hooks:delete(c2s_session_resumed, Host, ?MODULE,
|
||||
c2s_session_resumed, 50),
|
||||
ejabberd_hooks:delete(c2s_handle_cast, Host, ?MODULE,
|
||||
c2s_handle_cast, 50),
|
||||
ejabberd_hooks:delete(c2s_handle_send, Host, ?MODULE,
|
||||
@ -475,6 +479,14 @@ c2s_copy_session(State, #{push_enabled := true,
|
||||
c2s_copy_session(State, _) ->
|
||||
State.
|
||||
|
||||
-spec c2s_session_resumed(c2s_state()) -> c2s_state().
|
||||
c2s_session_resumed(#{push_session_id := ID,
|
||||
user := U, server := S, resource := R} = State) ->
|
||||
ejabberd_sm:set_user_info(U, S, R, push_id, ID),
|
||||
State;
|
||||
c2s_session_resumed(State) ->
|
||||
State.
|
||||
|
||||
-spec c2s_handle_cast(c2s_state(), any()) -> c2s_state() | {stop, c2s_state()}.
|
||||
c2s_handle_cast(State, {push_enable, ID}) ->
|
||||
{stop, State#{push_enabled => true,
|
||||
|
Loading…
Reference in New Issue
Block a user