24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-08 21:43:07 +02:00

fix node path format, must be binary()

This commit is contained in:
Christophe Romain 2010-04-27 19:08:56 +02:00
parent 4c147c5f29
commit b49dd8b8c4
8 changed files with 32 additions and 41 deletions

View File

@ -288,7 +288,7 @@ init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
case lists:member("hometree", Plugins) of
true ->
create_node(Host, ServerHost, string_to_node("/home"), service_jid(Host), "hometree"),
create_node(Host, ServerHost, string_to_node("/home" ++ ServerHost), service_jid(Host), "hometree");
create_node(Host, ServerHost, string_to_node("/home/" ++ ServerHost), service_jid(Host), "hometree");
false ->
ok
end.

View File

@ -60,8 +60,8 @@
get_item/2,
set_item/1,
get_item_name/3,
node_to_path/1,
path_to_node/1
node_to_path/1,
path_to_node/1
]).
@ -185,12 +185,12 @@ get_item_name(Host, Node, Id) ->
node_hometree:get_item_name(Host, Node, Id).
node_to_path(Node) ->
[binary_to_list(Node)].
[Node].
path_to_node(Path) ->
case Path of
% default slot
[Node] -> list_to_binary(Node);
[Node] -> Node;
% handle old possible entries, used when migrating database content to new format
[Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/"));
% default case (used by PEP for example)

View File

@ -61,8 +61,8 @@
set_item/1,
get_item_name/3,
get_last_items/3,
node_to_path/1,
path_to_node/1
node_to_path/1,
path_to_node/1
]).
@ -191,14 +191,7 @@ get_last_items(NodeId, From, Count) ->
node_hometree_odbc:get_last_items(NodeId, From, Count).
node_to_path(Node) ->
[binary_to_list(Node)].
node_flat:node_to_path(Node).
path_to_node(Path) ->
case Path of
% default slot
[Node] -> list_to_binary(Node);
% handle old possible entries, used when migrating database content to new format
[Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/"));
% default case (used by PEP for example)
_ -> list_to_binary(Path)
end.
node_flat:path_to_node(Path).

View File

@ -76,8 +76,8 @@
get_item/2,
set_item/1,
get_item_name/3,
node_to_path/1,
path_to_node/1
node_to_path/1,
path_to_node/1
]).
%% ================
@ -208,7 +208,7 @@ create_node_permission(Host, ServerHost, Node, _ParentNode, Owner, Access) ->
case acl:match_rule(ServerHost, Access, exmpp_jid:make(LU, LS, LR)) of
allow ->
case node_to_path(Node) of
["home", Server, User | _] -> true;
[<<"home">>, Server, User | _] -> true;
_ -> false
end;
_ ->
@ -986,12 +986,12 @@ get_item_name(_Host, _Node, Id) ->
Id.
node_to_path(Node) ->
string:tokens(binary_to_list(Node), "/").
[list_to_binary(Item) || Item <- string:tokens(binary_to_list(Node), "/")].
path_to_node([]) ->
<<>>;
path_to_node(Path) ->
list_to_binary(string:join([""|Path], "/")).
list_to_binary(string:join([""|[binary_to_list(Item) || Item <- Path]], "/")).
%% @spec (Affiliation, Subscription) -> true | false
%% Affiliation = owner | member | publisher | outcast | none

View File

@ -239,7 +239,7 @@ create_node(NodeId, Owner) ->
%% Removed = [mod_pubsub:pubsubNode()]
%% @doc <p>purge items of deleted nodes after effective deletion.</p>
delete_node(Removed) ->
%% pablo: TODO, this is present on trunk/node_home_tree but not on trunk/node_home_tree_odbc.
%% pablo: TODO, this is present on trunk/node_hometree but not on trunk/node_hometree_odbc.
%% check what is the desired behaviour
%% Tr = fun(#pubsub_state{stateid = {J, _}, subscriptions = Ss}) ->
%% lists:map(fun(S) ->
@ -1382,9 +1382,7 @@ i2l(L, N) when is_list(L) ->
end.
node_to_path(Node) ->
string:tokens(binary_to_list(Node), "/").
node_hometree:node_to_path(Node).
path_to_node([]) ->
<<>>;
path_to_node(Path) ->
list_to_binary(string:join([""|Path], "/")).
node_hometree:path_to_node(Path).

View File

@ -66,8 +66,8 @@
get_item/2,
set_item/1,
get_item_name/3,
node_to_path/1,
path_to_node/1
node_to_path/1,
path_to_node/1
]).
init(Host, ServerHost, Opts) ->

View File

@ -70,9 +70,9 @@
get_item/2,
set_item/1,
get_item_name/3,
get_last_items/3,
node_to_path/1,
path_to_node/1
get_last_items/3,
node_to_path/1,
path_to_node/1
]).
init(Host, ServerHost, Opts) ->

View File

@ -212,15 +212,15 @@ create_node(Host, Node, Type, Owner, Options, Parents) ->
true;
_ ->
case Parents of
[] -> true;
[Parent | _] ->
case mnesia:read({pubsub_node, {Host, Parent}}) of
[#pubsub_node{owners = [{[], Host, []}]}] -> true;
[#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners);
_ -> false
end;
_ ->
false
[] -> true;
[Parent | _] ->
case mnesia:read({pubsub_node, {Host, Parent}}) of
[#pubsub_node{owners = [{undefined, Host, undefined}]}] -> true;
[#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners);
_ -> false
end;
_ ->
false
end
end,
case ParentExists of