apply filtered notification to PEP last items (thanks to karim Gemayel)(EJAB-1456)

This commit is contained in:
Christophe Romain 2011-05-31 15:40:07 +02:00
parent 370093afde
commit 8faafc5b0d
1 changed files with 30 additions and 4 deletions

View File

@ -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()