]> granicus.if.org Git - ejabberd/commitdiff
ODBC: Sync last item notifications with mod_pubsub
authorHolger Weiss <holger@zedat.fu-berlin.de>
Thu, 13 Nov 2014 23:02:59 +0000 (00:02 +0100)
committerHolger Weiss <holger@zedat.fu-berlin.de>
Thu, 13 Nov 2014 23:02:59 +0000 (00:02 +0100)
A while back, mod_pubsub was modified to address EJAB-1456.  However,
the change was only partially applied to mod_pubsub_odbc.  This commit
adds the remaining part.

src/mod_pubsub_odbc.erl

index 53329d33291d24e632936af76920353d85962b2e..87d5535238b821bacfb728cdfb9281531387c462 100644 (file)
@@ -2986,7 +2986,7 @@ get_allowed_items_call(Host, NodeIdx, From, Type, Options, Owners, RSM) ->
 %%      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) ->
     Stanza = case get_cached_item(Host, NodeId) of
        undefined ->
            % special ODBC optimization, works only with node_hometree_odbc, node_flat_odbc and node_pep_odbc
@@ -3011,7 +3011,19 @@ send_items(Host, Node, NodeId, Type, LJID, last) ->
                                                       itemsEls([LastItem])}],
                                           ModifNow, ModifUSR)
     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,
+                                       <<((Node))/binary, "+notify">>},
+                                      _Sender = service_jid(Host), Stanza);
+           _ -> ok
+         end
+    end;
 send_items(Host, Node, NodeId, Type, {U, S, R} = LJID, Number) ->
     ToSend = case node_action(Host, Type, get_items,
                              [NodeId, LJID])