mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
Implement parentnodes seek for hometree (#1921)
This commit is contained in:
parent
daed6a05a6
commit
474536817e
@ -86,15 +86,26 @@ get_nodes(Host, _From) ->
|
|||||||
get_nodes(Host) ->
|
get_nodes(Host) ->
|
||||||
mnesia:match_object(#pubsub_node{nodeid = {Host, '_'}, _ = '_'}).
|
mnesia:match_object(#pubsub_node{nodeid = {Host, '_'}, _ = '_'}).
|
||||||
|
|
||||||
get_parentnodes(_Host, _Node, _From) ->
|
get_parentnodes(Host, Node, _From) ->
|
||||||
[].
|
|
||||||
|
|
||||||
%% @doc <p>Default node tree does not handle parents, return a list
|
|
||||||
%% containing just this node.</p>
|
|
||||||
get_parentnodes_tree(Host, Node, _From) ->
|
|
||||||
case catch mnesia:read({pubsub_node, {Host, Node}}) of
|
case catch mnesia:read({pubsub_node, {Host, Node}}) of
|
||||||
[Record] when is_record(Record, pubsub_node) -> [{0, [Record]}];
|
[Record] when is_record(Record, pubsub_node) ->
|
||||||
_ -> []
|
Record#pubsub_node.parents;
|
||||||
|
_ ->
|
||||||
|
[]
|
||||||
|
end.
|
||||||
|
|
||||||
|
get_parentnodes_tree(Host, Node, _From) ->
|
||||||
|
get_parentnodes_tree(Host, Node, 0, []).
|
||||||
|
get_parentnodes_tree(Host, Node, Level, Acc) ->
|
||||||
|
case catch mnesia:read({pubsub_node, {Host, Node}}) of
|
||||||
|
[Record] when is_record(Record, pubsub_node) ->
|
||||||
|
Tree = [{Level, [Record]}|Acc],
|
||||||
|
case Record#pubsub_node.parents of
|
||||||
|
[Parent] -> get_parentnodes_tree(Host, Parent, Level+1, Tree);
|
||||||
|
_ -> Tree
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
Acc
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_subnodes(Host, Node, _From) ->
|
get_subnodes(Host, Node, _From) ->
|
||||||
|
@ -160,15 +160,26 @@ get_nodes(Host) ->
|
|||||||
[]
|
[]
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_parentnodes(_Host, _Node, _From) ->
|
get_parentnodes(Host, Node, _From) ->
|
||||||
[].
|
case get_node(Host, Node) of
|
||||||
|
Record when is_record(Record, pubsub_node) ->
|
||||||
|
Record#pubsub_node.parents;
|
||||||
|
_ ->
|
||||||
|
[]
|
||||||
|
end.
|
||||||
|
|
||||||
%% @doc <p>Default node tree does not handle parents, return a list
|
get_parentnodes_tree(Host, Node, _From) ->
|
||||||
%% containing just this node.</p>
|
get_parentnodes_tree(Host, Node, 0, []).
|
||||||
get_parentnodes_tree(Host, Node, From) ->
|
get_parentnodes_tree(Host, Node, Level, Acc) ->
|
||||||
case get_node(Host, Node, From) of
|
case get_node(Host, Node) of
|
||||||
{error, _} -> [];
|
Record when is_record(Record, pubsub_node) ->
|
||||||
Record -> [{0, [Record]}]
|
Tree = [{Level, [Record]}|Acc],
|
||||||
|
case Record#pubsub_node.parents of
|
||||||
|
[Parent] -> get_parentnodes_tree(Host, Parent, Level+1, Tree);
|
||||||
|
_ -> Tree
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
Acc
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_subnodes(Host, Node, _From) ->
|
get_subnodes(Host, Node, _From) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user