pubsub identity and database update bugfix
authorChristophe Romain <christophe.romain@process-one.net>
Thu, 10 Apr 2008 14:11:06 +0000 (14:11 +0000)
committerChristophe Romain <christophe.romain@process-one.net>
Thu, 10 Apr 2008 14:11:06 +0000 (14:11 +0000)
SVN Revision: 1285

ChangeLog
src/mod_pubsub/mod_pubsub.erl
src/mod_pubsub/nodetree_default.erl

index 2bcc8e9a1135ead0bddd63085dcb9a6495c2948d..f8dc5b0b712301c54245ef2a7c47b8eea2d435a9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
+2008-04-10  Christophe Romain <christophe.romain@process-one.net>
+
+       * src/mod_pubsub/mod_pubsub.erl: fix identity and database update
+       bugfix
+       * src/mod_pubsub/nodetree_default.erl: Likewise
+
 2008-04-10  Mickael Remond  <mremond@process-one.net>
 
-       *src/ejabberd_c2s.erl: Uniform default value for empty privacy
+       * src/ejabberd_c2s.erl: Uniform default value for empty privacy
        list. Fixes (EJAB-603).
 
 2008-04-08  Badlop  <badlop@process-one.net>
index 43bd7d9ac198c9449c21a465d1a06d33856b0cb2..134629c2781bdfa3190a63616f00c0c74e7d85e9 100644 (file)
@@ -232,7 +232,7 @@ init_nodes(Host, ServerHost, ServedHosts) ->
     lists:foreach(
       fun(H) ->
              create_node(Host, ServerHost, ["home", H], service_jid(Host), ?STDNODE)
-      end, [ServerHost | ServedHosts]),
+      end, lists:usort([ServerHost | ServedHosts])),
     ok.
 
 update_database(Host) ->
@@ -306,7 +306,7 @@ update_database(Host) ->
 identity(Host) ->
     Identity = case lists:member(?PEPNODE, plugins(Host)) of
     true -> [{"category", "pubsub"}, {"type", "pep"}];
-    false -> [{"category", "pubsub"}]
+    false -> [{"category", "pubsub"}, {"type", "service"}]
     end,
     {xmlelement, "identity", Identity, []}.
 
@@ -2280,38 +2280,44 @@ broadcast_by_caps({LUser, LServer, LResource}, Node, _Type, Stanza) ->
                                 [R|_] ->
                                     R;
                                 [] ->
-                                    ?ERROR_MSG("~p@~p is offline; can't deliver ~p to contacts", [LUser, LServer, Stanza]),
                                     ""
                             end;
                         _ ->
                             LResource
                     end,
-    case ejabberd_sm:get_session_pid(LUser, LServer, SenderResource) of
-       C2SPid when is_pid(C2SPid) ->
-           %% set the from address on the notification to the bare JID of the account owner
-           %% Also, add "replyto" if entity has presence subscription to the account owner
-           %% See XEP-0163 1.1 section 4.3.1
-           Sender = jlib:make_jid(LUser, LServer, ""),
-           %%ReplyTo = jlib:make_jid(LUser, LServer, SenderResource),  % This has to be used
-           case catch ejabberd_c2s:get_subscribed_and_online(C2SPid) of
-               ContactsWithCaps when is_list(ContactsWithCaps) ->
-                   ?DEBUG("found contacts with caps: ~p", [ContactsWithCaps]),
-                   lists:foreach(
-                     fun({JID, Caps}) ->
-                           case is_caps_notify(LServer, Node, Caps) of
-                               true ->
-                                   To = jlib:make_jid(JID),
-                                   ejabberd_router ! {route, Sender, To, Stanza};
-                               false ->
-                                   ok
-                           end
-                     end, ContactsWithCaps);
-               _ ->
-                   ok
-           end,
-           ok;
-       _ ->
-           ok
+    case SenderResource of
+    "" ->
+       ?DEBUG("~p@~p is offline; can't deliver ~p to contacts", [LUser, LServer, Stanza]),
+       ok;
+    _ ->
+       case ejabberd_sm:get_session_pid(LUser, LServer, SenderResource) of
+           C2SPid when is_pid(C2SPid) ->
+               %% set the from address on the notification to the bare JID of the account owner
+               %% Also, add "replyto" if entity has presence subscription to the account owner
+               %% See XEP-0163 1.1 section 4.3.1
+               Sender = jlib:make_jid(LUser, LServer, ""),
+               %%ReplyTo = jlib:make_jid(LUser, LServer, SenderResource),  % This has to be used
+               case catch ejabberd_c2s:get_subscribed_and_online(C2SPid) of
+                   ContactsWithCaps when is_list(ContactsWithCaps) ->
+                       ?DEBUG("found contacts with caps: ~p", [ContactsWithCaps]),
+                       lists:foreach(
+                       fun({JID, Caps}) ->
+                               case is_caps_notify(LServer, Node, Caps) of
+                                   true ->
+                                       To = jlib:make_jid(JID),
+                                       ejabberd_router ! {route, Sender, To, Stanza};
+                                   false ->
+                                       ok
+                               end
+                       end, ContactsWithCaps);
+                   _ ->
+                       ok
+               end,
+               ok;
+           _ ->
+               ?DEBUG("~p@~p has no session; can't deliver ~p to contacts", [LUser, LServer, Stanza]),
+               ok
+       end
     end;
 broadcast_by_caps(_, _, _, _) ->
     ok.
index 0a36e3362f0a7087e3fe13f9686ed54069be7810..6dec6c5e47373672c8ba2ffe63d1626b3489854f 100644 (file)
@@ -74,6 +74,7 @@ init(_Host, _ServerHost, _Opts) ->
                         {index, [type,parentid]}]),
     NodesFields = record_info(fields, pubsub_node),
     case mnesia:table_info(pubsub_node, attributes) of
+       [host_node, host_parent, info] -> ok;  % old schema, updated later by pubsub
        NodesFields -> ok;
        _ -> mnesia:transform_table(pubsub_node, ignore, NodesFields)
     end,