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

avoid sending empty events

This commit is contained in:
Christophe Romain 2014-05-05 13:51:02 +02:00
parent 530ac43758
commit faa6ad26a0
2 changed files with 26 additions and 5 deletions

View File

@ -3356,6 +3356,8 @@ send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
_ -> []
end,
Stanza = case ToSend of
[] ->
undefined;
[LastItem] ->
{ModifNow, ModifUSR} =
LastItem#pubsub_item.modification,
@ -3369,11 +3371,13 @@ send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
attrs = nodeAttr(Node),
children = itemsEls(ToSend)}])
end,
case is_tuple(Host) of
false ->
case {is_tuple(Host), Stanza} of
{_, undefined} ->
ok;
{false, _} ->
ejabberd_router:route(service_jid(Host),
jlib:make_jid(LJID), Stanza);
true ->
{true, _} ->
case ejabberd_sm:get_session_pid(U, S, R) of
C2SPid when is_pid(C2SPid) ->
ejabberd_c2s:broadcast(C2SPid,

View File

@ -3013,7 +3013,7 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
ModifNow, ModifUSR)
end,
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza);
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
@ -3026,6 +3026,8 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
_ -> []
end,
Stanza = case ToSend of
[] ->
undefined;
[LastItem] ->
{ModifNow, ModifUSR} =
LastItem#pubsub_item.modification,
@ -3039,7 +3041,22 @@ send_items(Host, Node, NodeId, Type, LJID, Number) ->
attrs = nodeAttr(Node),
children = itemsEls(ToSend)}])
end,
ejabberd_router:route(service_jid(Host), jlib:make_jid(LJID), Stanza).
case {is_tuple(Host), Stanza} of
{_, undefined} ->
ok;
{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,
<<((Node))/binary, "+notify">>},
_Sender = service_jid(Host), Stanza);
_ -> ok
end
end.
%% @spec (Host, JID, Plugins) -> {error, Reason} | {result, Response}
%% Host = host()