]> granicus.if.org Git - ejabberd/commitdiff
XEP-0248 bugfix (EJAB-963) (Thanks to Brian Cully)
authorChristophe Romain <christophe.romain@process-one.net>
Mon, 6 Jul 2009 08:05:33 +0000 (08:05 +0000)
committerChristophe Romain <christophe.romain@process-one.net>
Mon, 6 Jul 2009 08:05:33 +0000 (08:05 +0000)
SVN Revision: 2353

src/mod_pubsub/nodetree_dag.erl

index 091bc52ad059d083662d4062b634f8924d7fe07f..7ddcaf18a0e12a1ce0470a9916beb38dbd65f272 100644 (file)
@@ -166,12 +166,13 @@ get_subnodes(Host, NodeID) ->
            qlc:e(Q)
     end.
 
-get_subnodes_tree(Host, NodeID, _From) ->
+get_subnodes_tree(Host, NodeID, From) ->
     Pred = fun (NID, #pubsub_node{parents = Parents}) ->
                   lists:member(NID, Parents)
           end,
-    Tr = fun (#pubsub_node{nodeid = {_, N}}) -> N end,
-    traversal_helper(Pred, Tr, Host, [NodeID]).
+    Tr = fun (#pubsub_node{nodeid = {_, N}}) -> [N] end,
+    traversal_helper(Pred, Tr, 1, Host, [NodeID],
+                     [{0, [get_node(Host, NodeID, From)]}]).
 
 %%====================================================================
 %% Internal functions
@@ -232,8 +233,9 @@ validate_parentage(Key, Owners, [ParentID | T]) ->
            MutualOwners = [O || O <- Owners, PO <- POwners,
                                 O == PO],
            case {MutualOwners, NodeType} of
-               {[], _}  -> {error, ?ERR_NOT_ALLOWED};
-               {_, collection} -> validate_parentage(Key, Owners, T)
+               {[], _}  -> {error, ?ERR_FORBIDDEN};
+               {_, collection} -> validate_parentage(Key, Owners, T);
+               {_, _} -> {error, ?ERR_NOT_ALLOWED}
            end
     end.