25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Send last PEP items to remote subscribers

When a remote subscriber becomes available, send him the last published
PEP items, as we do for local subscribers.

However, the current implementation depends on a running ejabberd_c2s
process of the publisher to send items to remote subscribers.  So, for
those, the behavior is always like it is for local subscribers when
"ignore_pep_from_offline" is set to "true".
This commit is contained in:
Holger Weiss 2014-11-14 01:33:11 +01:00
parent 830fdccd21
commit f69d1ca282
2 changed files with 34 additions and 16 deletions

View File

@ -3367,14 +3367,23 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
). ).
dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok; dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok;
dispatch_items(From, {ToU, ToS, ToR} = To, Node, Stanza) -> dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of Stanza) ->
C2SPid when is_pid(C2SPid) -> C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
ejabberd_c2s:send_filtered(C2SPid, ToPid when is_pid(ToPid) -> ToPid;
{pep_message, <<Node/binary, "+notify">>}, _ ->
service_jid(From), jlib:make_jid(To), R = user_resource(FromU, FromS, FromR),
Stanza) case ejabberd_sm:get_session_pid(FromU, FromS, R) of
_ -> ok FromPid when is_pid(FromPid) -> FromPid;
_ -> undefined
end
end,
if C2SPid == undefined -> ok;
true ->
ejabberd_c2s:send_filtered(C2SPid,
{pep_message, <<Node/binary, "+notify">>},
service_jid(From), jlib:make_jid(To),
Stanza)
end; end;
dispatch_items(From, To, _Node, Stanza) -> dispatch_items(From, To, _Node, Stanza) ->
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza). ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).

View File

@ -3052,14 +3052,23 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
). ).
dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok; dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok;
dispatch_items(From, {ToU, ToS, ToR} = To, Node, Stanza) -> dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of Stanza) ->
C2SPid when is_pid(C2SPid) -> C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
ejabberd_c2s:send_filtered(C2SPid, ToPid when is_pid(ToPid) -> ToPid;
{pep_message, <<Node/binary, "+notify">>}, _ ->
service_jid(From), jlib:make_jid(To), R = user_resource(FromU, FromS, FromR),
Stanza) case ejabberd_sm:get_session_pid(FromU, FromS, R) of
_ -> ok FromPid when is_pid(FromPid) -> FromPid;
_ -> undefined
end
end,
if C2SPid == undefined -> ok;
true ->
ejabberd_c2s:send_filtered(C2SPid,
{pep_message, <<Node/binary, "+notify">>},
service_jid(From), jlib:make_jid(To),
Stanza)
end; end;
dispatch_items(From, To, _Node, Stanza) -> dispatch_items(From, To, _Node, Stanza) ->
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza). ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).