25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +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, end,
Stanza = case ToSend of Stanza = case ToSend of
[] ->
undefined;
[LastItem] -> [LastItem] ->
{ModifNow, ModifUSR} = {ModifNow, ModifUSR} =
LastItem#pubsub_item.modification, LastItem#pubsub_item.modification,
@ -3369,11 +3371,13 @@ send_items(Host, Node, NodeId, Type, {U, S, R} = LJID,
attrs = nodeAttr(Node), attrs = nodeAttr(Node),
children = itemsEls(ToSend)}]) children = itemsEls(ToSend)}])
end, end,
case is_tuple(Host) of case {is_tuple(Host), Stanza} of
false -> {_, undefined} ->
ok;
{false, _} ->
ejabberd_router:route(service_jid(Host), ejabberd_router:route(service_jid(Host),
jlib:make_jid(LJID), Stanza); jlib:make_jid(LJID), Stanza);
true -> {true, _} ->
case ejabberd_sm:get_session_pid(U, S, R) of case ejabberd_sm:get_session_pid(U, S, R) of
C2SPid when is_pid(C2SPid) -> C2SPid when is_pid(C2SPid) ->
ejabberd_c2s:broadcast(C2SPid, ejabberd_c2s:broadcast(C2SPid,

View File

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