aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2011-05-31 15:40:07 +0200
committerChristophe Romain <christophe.romain@process-one.net>2011-05-31 15:40:07 +0200
commit8faafc5b0d30e587e842bf3b2ada6b33f89e60bd (patch)
tree8c67ad3528501d10b63a91a7d331627c50a4053c
parentFix minor English error (diff)
apply filtered notification to PEP last items (thanks to karim Gemayel)(EJAB-1456)
-rw-r--r--src/mod_pubsub/mod_pubsub.erl34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/mod_pubsub/mod_pubsub.erl b/src/mod_pubsub/mod_pubsub.erl
index aa6d50539..b0befbcb7 100644
--- a/src/mod_pubsub/mod_pubsub.erl
+++ b/src/mod_pubsub/mod_pubsub.erl
@@ -2317,7 +2317,7 @@ get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners) ->
%% Number = last | integer()
%% @doc <p>Resend the items of a node to the user.</p>
%% @todo use cache-last-item feature
-send_items(Host, Node, NodeId, Type, LJID, last) ->
+send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, last) ->
case get_cached_item(Host, NodeId) of
undefined ->
send_items(Host, Node, NodeId, Type, LJID, 1);
@@ -2326,9 +2326,22 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
Stanza = event_stanza_with_delay(
[{xmlelement, "items", nodeAttr(Node),
itemsEls([LastItem])}], ModifNow, ModifUSR),
- ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza)
+ case is_tuple(Host) of
+ false ->
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
+ true ->
+ case ejabberd_sm:get_session_pid(U,S,R) of
+ C2SPid when is_pid(C2SPid) ->
+ ejabberd_c2s:broadcast(C2SPid,
+ {pep_message, binary_to_list(Node)++"+notify"},
+ _Sender = service_jid(Host),
+ Stanza);
+ _ ->
+ ok
+ end
+ end
end;
-send_items(Host, Node, NodeId, Type, LJID, Number) ->
+send_items(Host, Node, NodeId, Type, {U,S,R} = LJID, Number) ->
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
{result, []} ->
[];
@@ -2351,7 +2364,20 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
[{xmlelement, "items", nodeAttr(Node),
itemsEls(ToSend)}])
end,
- ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza).
+ case is_tuple(Host) of
+ false ->
+ ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
+ true ->
+ case ejabberd_sm:get_session_pid(U,S,R) of
+ C2SPid when is_pid(C2SPid) ->
+ ejabberd_c2s:broadcast(C2SPid,
+ {pep_message, binary_to_list(Node)++"+notify"},
+ _Sender = service_jid(Host),
+ Stanza);
+ _ ->
+ ok
+ end
+ end.
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
%% Host = host()