aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristophe Romain <christophe.romain@process-one.net>2014-05-05 13:51:02 +0200
committerChristophe Romain <christophe.romain@process-one.net>2014-05-05 17:53:44 +0200
commitfaa6ad26a0d1a0968b008642f64a3a5766f9a40e (patch)
treedd6de4f8f2d40b938fa9290d702ff3b3b308b568 /src
parentstore item when persist_item=false and cache_last_item=false but need last_item (diff)
avoid sending empty events
Diffstat (limited to 'src')
-rw-r--r--src/mod_pubsub.erl10
-rw-r--r--src/mod_pubsub_odbc.erl21
2 files changed, 26 insertions, 5 deletions
diff --git a/src/mod_pubsub.erl b/src/mod_pubsub.erl
index 8cbd994e0..1d8bd143c 100644
--- a/src/mod_pubsub.erl
+++ b/src/mod_pubsub.erl
@@ -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,
diff --git a/src/mod_pubsub_odbc.erl b/src/mod_pubsub_odbc.erl
index 8236447d0..498c81bd3 100644
--- a/src/mod_pubsub_odbc.erl
+++ b/src/mod_pubsub_odbc.erl
@@ -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()