mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
fix node path format, must be binary()
This commit is contained in:
parent
4c147c5f29
commit
b49dd8b8c4
@ -288,7 +288,7 @@ init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
|||||||
case lists:member("hometree", Plugins) of
|
case lists:member("hometree", Plugins) of
|
||||||
true ->
|
true ->
|
||||||
create_node(Host, ServerHost, string_to_node("/home"), service_jid(Host), "hometree"),
|
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 ->
|
false ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
@ -60,8 +60,8 @@
|
|||||||
get_item/2,
|
get_item/2,
|
||||||
set_item/1,
|
set_item/1,
|
||||||
get_item_name/3,
|
get_item_name/3,
|
||||||
node_to_path/1,
|
node_to_path/1,
|
||||||
path_to_node/1
|
path_to_node/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
|
|
||||||
@ -185,12 +185,12 @@ get_item_name(Host, Node, Id) ->
|
|||||||
node_hometree:get_item_name(Host, Node, Id).
|
node_hometree:get_item_name(Host, Node, Id).
|
||||||
|
|
||||||
node_to_path(Node) ->
|
node_to_path(Node) ->
|
||||||
[binary_to_list(Node)].
|
[Node].
|
||||||
|
|
||||||
path_to_node(Path) ->
|
path_to_node(Path) ->
|
||||||
case Path of
|
case Path of
|
||||||
% default slot
|
% default slot
|
||||||
[Node] -> list_to_binary(Node);
|
[Node] -> Node;
|
||||||
% handle old possible entries, used when migrating database content to new format
|
% handle old possible entries, used when migrating database content to new format
|
||||||
[Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/"));
|
[Node|_] when is_list(Node) -> list_to_binary(string:join([""|Path], "/"));
|
||||||
% default case (used by PEP for example)
|
% default case (used by PEP for example)
|
||||||
|
@ -61,8 +61,8 @@
|
|||||||
set_item/1,
|
set_item/1,
|
||||||
get_item_name/3,
|
get_item_name/3,
|
||||||
get_last_items/3,
|
get_last_items/3,
|
||||||
node_to_path/1,
|
node_to_path/1,
|
||||||
path_to_node/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_hometree_odbc:get_last_items(NodeId, From, Count).
|
||||||
|
|
||||||
node_to_path(Node) ->
|
node_to_path(Node) ->
|
||||||
[binary_to_list(Node)].
|
node_flat:node_to_path(Node).
|
||||||
|
|
||||||
path_to_node(Path) ->
|
path_to_node(Path) ->
|
||||||
case Path of
|
node_flat:path_to_node(Path).
|
||||||
% 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.
|
|
||||||
|
@ -76,8 +76,8 @@
|
|||||||
get_item/2,
|
get_item/2,
|
||||||
set_item/1,
|
set_item/1,
|
||||||
get_item_name/3,
|
get_item_name/3,
|
||||||
node_to_path/1,
|
node_to_path/1,
|
||||||
path_to_node/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
|
case acl:match_rule(ServerHost, Access, exmpp_jid:make(LU, LS, LR)) of
|
||||||
allow ->
|
allow ->
|
||||||
case node_to_path(Node) of
|
case node_to_path(Node) of
|
||||||
["home", Server, User | _] -> true;
|
[<<"home">>, Server, User | _] -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
@ -986,12 +986,12 @@ get_item_name(_Host, _Node, Id) ->
|
|||||||
Id.
|
Id.
|
||||||
|
|
||||||
node_to_path(Node) ->
|
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_to_node(Path) ->
|
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
|
%% @spec (Affiliation, Subscription) -> true | false
|
||||||
%% Affiliation = owner | member | publisher | outcast | none
|
%% Affiliation = owner | member | publisher | outcast | none
|
||||||
|
@ -239,7 +239,7 @@ create_node(NodeId, Owner) ->
|
|||||||
%% Removed = [mod_pubsub:pubsubNode()]
|
%% Removed = [mod_pubsub:pubsubNode()]
|
||||||
%% @doc <p>purge items of deleted nodes after effective deletion.</p>
|
%% @doc <p>purge items of deleted nodes after effective deletion.</p>
|
||||||
delete_node(Removed) ->
|
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
|
%% check what is the desired behaviour
|
||||||
%% Tr = fun(#pubsub_state{stateid = {J, _}, subscriptions = Ss}) ->
|
%% Tr = fun(#pubsub_state{stateid = {J, _}, subscriptions = Ss}) ->
|
||||||
%% lists:map(fun(S) ->
|
%% lists:map(fun(S) ->
|
||||||
@ -1382,9 +1382,7 @@ i2l(L, N) when is_list(L) ->
|
|||||||
end.
|
end.
|
||||||
|
|
||||||
node_to_path(Node) ->
|
node_to_path(Node) ->
|
||||||
string:tokens(binary_to_list(Node), "/").
|
node_hometree:node_to_path(Node).
|
||||||
|
|
||||||
path_to_node([]) ->
|
|
||||||
<<>>;
|
|
||||||
path_to_node(Path) ->
|
path_to_node(Path) ->
|
||||||
list_to_binary(string:join([""|Path], "/")).
|
node_hometree:path_to_node(Path).
|
||||||
|
@ -66,8 +66,8 @@
|
|||||||
get_item/2,
|
get_item/2,
|
||||||
set_item/1,
|
set_item/1,
|
||||||
get_item_name/3,
|
get_item_name/3,
|
||||||
node_to_path/1,
|
node_to_path/1,
|
||||||
path_to_node/1
|
path_to_node/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
init(Host, ServerHost, Opts) ->
|
init(Host, ServerHost, Opts) ->
|
||||||
|
@ -70,9 +70,9 @@
|
|||||||
get_item/2,
|
get_item/2,
|
||||||
set_item/1,
|
set_item/1,
|
||||||
get_item_name/3,
|
get_item_name/3,
|
||||||
get_last_items/3,
|
get_last_items/3,
|
||||||
node_to_path/1,
|
node_to_path/1,
|
||||||
path_to_node/1
|
path_to_node/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
init(Host, ServerHost, Opts) ->
|
init(Host, ServerHost, Opts) ->
|
||||||
|
@ -212,15 +212,15 @@ create_node(Host, Node, Type, Owner, Options, Parents) ->
|
|||||||
true;
|
true;
|
||||||
_ ->
|
_ ->
|
||||||
case Parents of
|
case Parents of
|
||||||
[] -> true;
|
[] -> true;
|
||||||
[Parent | _] ->
|
[Parent | _] ->
|
||||||
case mnesia:read({pubsub_node, {Host, Parent}}) of
|
case mnesia:read({pubsub_node, {Host, Parent}}) of
|
||||||
[#pubsub_node{owners = [{[], Host, []}]}] -> true;
|
[#pubsub_node{owners = [{undefined, Host, undefined}]}] -> true;
|
||||||
[#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners);
|
[#pubsub_node{owners = Owners}] -> lists:member(BJID, Owners);
|
||||||
_ -> false
|
_ -> false
|
||||||
end;
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
case ParentExists of
|
case ParentExists of
|
||||||
|
Loading…
Reference in New Issue
Block a user