mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
mod_pubsub: Send last items on initial presence
Wait until we got initial presence from the client before sending the last items of nodes the JID is subscribed to. Closes #2132.
This commit is contained in:
parent
57e3f49352
commit
03246f5ff4
@ -52,7 +52,7 @@
|
|||||||
%% exports for hooks
|
%% exports for hooks
|
||||||
-export([presence_probe/3, caps_add/3, caps_update/3,
|
-export([presence_probe/3, caps_add/3, caps_update/3,
|
||||||
in_subscription/6, out_subscription/4,
|
in_subscription/6, out_subscription/4,
|
||||||
on_user_online/1, on_user_offline/2, remove_user/2,
|
on_self_presence/1, on_user_offline/2, remove_user/2,
|
||||||
disco_local_identity/5, disco_local_features/5,
|
disco_local_identity/5, disco_local_features/5,
|
||||||
disco_local_items/5, disco_sm_identity/5,
|
disco_local_items/5, disco_sm_identity/5,
|
||||||
disco_sm_features/5, disco_sm_items/5,
|
disco_sm_features/5, disco_sm_items/5,
|
||||||
@ -296,8 +296,8 @@ init([ServerHost, Opts]) ->
|
|||||||
?MODULE, process_commands, IQDisc),
|
?MODULE, process_commands, IQDisc),
|
||||||
Plugins
|
Plugins
|
||||||
end, Hosts),
|
end, Hosts),
|
||||||
ejabberd_hooks:add(c2s_session_opened, ServerHost,
|
ejabberd_hooks:add(c2s_self_presence, ServerHost,
|
||||||
?MODULE, on_user_online, 75),
|
?MODULE, on_self_presence, 75),
|
||||||
ejabberd_hooks:add(c2s_terminated, ServerHost,
|
ejabberd_hooks:add(c2s_terminated, ServerHost,
|
||||||
?MODULE, on_user_offline, 75),
|
?MODULE, on_user_offline, 75),
|
||||||
ejabberd_hooks:add(disco_local_identity, ServerHost,
|
ejabberd_hooks:add(disco_local_identity, ServerHost,
|
||||||
@ -579,11 +579,15 @@ presence_probe(_From, _To, _Pid) ->
|
|||||||
%% ignore presence_probe from remote contacts, those are handled via caps_add
|
%% ignore presence_probe from remote contacts, those are handled via caps_add
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
-spec on_user_online(ejabberd_c2s:state()) -> ejabberd_c2s:state().
|
-spec on_self_presence({presence(), ejabberd_c2s:state()})
|
||||||
on_user_online(C2SState) ->
|
-> {presence(), ejabberd_c2s:state()}.
|
||||||
JID = maps:get(jid, C2SState),
|
on_self_presence({_, #{pres_last := _}} = Acc) -> % Just a presence update.
|
||||||
|
Acc;
|
||||||
|
on_self_presence({#presence{type = available}, #{jid := JID}} = Acc) ->
|
||||||
send_last_items(JID),
|
send_last_items(JID),
|
||||||
C2SState.
|
Acc;
|
||||||
|
on_self_presence(Acc) ->
|
||||||
|
Acc.
|
||||||
|
|
||||||
-spec on_user_offline(ejabberd_c2s:state(), atom()) -> ejabberd_c2s:state().
|
-spec on_user_offline(ejabberd_c2s:state(), atom()) -> ejabberd_c2s:state().
|
||||||
on_user_offline(#{jid := JID} = C2SState, _Reason) ->
|
on_user_offline(#{jid := JID} = C2SState, _Reason) ->
|
||||||
@ -769,8 +773,8 @@ terminate(_Reason,
|
|||||||
false ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ejabberd_hooks:delete(c2s_session_opened, ServerHost,
|
ejabberd_hooks:delete(c2s_self_presence, ServerHost,
|
||||||
?MODULE, on_user_online, 75),
|
?MODULE, on_self_presence, 75),
|
||||||
ejabberd_hooks:delete(c2s_terminated, ServerHost,
|
ejabberd_hooks:delete(c2s_terminated, ServerHost,
|
||||||
?MODULE, on_user_offline, 75),
|
?MODULE, on_user_offline, 75),
|
||||||
ejabberd_hooks:delete(disco_local_identity, ServerHost,
|
ejabberd_hooks:delete(disco_local_identity, ServerHost,
|
||||||
|
Loading…
Reference in New Issue
Block a user