aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-11-14 01:33:11 +0100
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-11-14 01:33:11 +0100
commitf69d1ca282486302ae21f056024134177ea4da66 (patch)
tree35ad6f6587467ce2e0a4ae86924b4c31043fc7f1
parentDon't broadcast last published PEP items (diff)
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".
-rw-r--r--src/mod_pubsub.erl25
-rw-r--r--src/mod_pubsub_odbc.erl25
2 files changed, 34 insertions, 16 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index c34b1583c..e6437199b 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -3367,14 +3367,23 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
).
dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok;
-dispatch_items(From, {ToU, ToS, ToR} = To, Node, Stanza) ->
- case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
- C2SPid when is_pid(C2SPid) ->
- ejabberd_c2s:send_filtered(C2SPid,
- {pep_message, <<Node/binary, "+notify">>},
- service_jid(From), jlib:make_jid(To),
- Stanza)
- _ -> ok
+dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
+ Stanza) ->
+ C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
+ ToPid when is_pid(ToPid) -> ToPid;
+ _ ->
+ R = user_resource(FromU, FromS, FromR),
+ case ejabberd_sm:get_session_pid(FromU, FromS, R) of
+ 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;
dispatch_items(From, To, _Node, Stanza) ->
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).
diff --git a/src/mod_pubsub_odbc.erl b/src/mod_pubsub_odbc.erl
index 8edd1250b..e2b357f03 100644
--- a/src/mod_pubsub_odbc.erl
+++ b/src/mod_pubsub_odbc.erl
@@ -3052,14 +3052,23 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
).
dispatch_items(_From, _To, _Node, _Stanza = undefined) -> ok;
-dispatch_items(From, {ToU, ToS, ToR} = To, Node, Stanza) ->
- case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
- C2SPid when is_pid(C2SPid) ->
- ejabberd_c2s:send_filtered(C2SPid,
- {pep_message, <<Node/binary, "+notify">>},
- service_jid(From), jlib:make_jid(To),
- Stanza)
- _ -> ok
+dispatch_items({FromU, FromS, FromR} = From, {ToU, ToS, ToR} = To, Node,
+ Stanza) ->
+ C2SPid = case ejabberd_sm:get_session_pid(ToU, ToS, ToR) of
+ ToPid when is_pid(ToPid) -> ToPid;
+ _ ->
+ R = user_resource(FromU, FromS, FromR),
+ case ejabberd_sm:get_session_pid(FromU, FromS, R) of
+ 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;
dispatch_items(From, To, _Node, Stanza) ->
ejabberd_router:route(service_jid(From), jlib:make_jid(To), Stanza).