mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
added function to rename old default nodes to hometree
SVN Revision: 2529
This commit is contained in:
parent
ca403c25e7
commit
3909f95ac1
@ -104,7 +104,8 @@
|
|||||||
string_to_subscription/1,
|
string_to_subscription/1,
|
||||||
string_to_affiliation/1,
|
string_to_affiliation/1,
|
||||||
extended_error/2,
|
extended_error/2,
|
||||||
extended_error/3
|
extended_error/3,
|
||||||
|
rename_default_nodeplugin/0
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% API and gen_server callbacks
|
%% API and gen_server callbacks
|
||||||
@ -334,11 +335,9 @@ update_node_database(Host, ServerHost) ->
|
|||||||
end,
|
end,
|
||||||
case mnesia:transaction(FNew) of
|
case mnesia:transaction(FNew) of
|
||||||
{atomic, Result} ->
|
{atomic, Result} ->
|
||||||
?INFO_MSG("Pubsub node tables updated correctly: ~p",
|
?INFO_MSG("Pubsub node tables updated correctly: ~p", [Result]);
|
||||||
[Result]);
|
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("Problem updating Pubsub node tables:~n~p",
|
?ERROR_MSG("Problem updating Pubsub node tables:~n~p", [Reason])
|
||||||
[Reason])
|
|
||||||
end;
|
end;
|
||||||
[nodeid, parentid, type, owners, options] ->
|
[nodeid, parentid, type, owners, options] ->
|
||||||
F = fun({pubsub_node, NodeId, {_, Parent}, Type, Owners, Options}) ->
|
F = fun({pubsub_node, NodeId, {_, Parent}, Type, Owners, Options}) ->
|
||||||
@ -377,11 +376,10 @@ update_node_database(Host, ServerHost) ->
|
|||||||
end,
|
end,
|
||||||
case mnesia:transaction(FNew) of
|
case mnesia:transaction(FNew) of
|
||||||
{atomic, Result} ->
|
{atomic, Result} ->
|
||||||
?INFO_MSG("Pubsub node tables updated correctly: ~p",
|
rename_default_nodeplugin(),
|
||||||
[Result]);
|
?INFO_MSG("Pubsub node tables updated correctly: ~p", [Result]);
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("Problem updating Pubsub node tables:~n~p",
|
?ERROR_MSG("Problem updating Pubsub node tables:~n~p", [Reason])
|
||||||
[Reason])
|
|
||||||
end;
|
end;
|
||||||
[nodeid, id, parent, type, owners, options] ->
|
[nodeid, id, parent, type, owners, options] ->
|
||||||
F = fun({pubsub_node, NodeId, Id, Parent, Type, Owners, Options}) ->
|
F = fun({pubsub_node, NodeId, Id, Parent, Type, Owners, Options}) ->
|
||||||
@ -393,11 +391,17 @@ update_node_database(Host, ServerHost) ->
|
|||||||
owners = Owners,
|
owners = Owners,
|
||||||
options = Options}
|
options = Options}
|
||||||
end,
|
end,
|
||||||
mnesia:transform_table(pubsub_node, F, [nodeid, id, parents, type, owners, options]);
|
mnesia:transform_table(pubsub_node, F, [nodeid, id, parents, type, owners, options]),
|
||||||
|
rename_default_nodeplugin();
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
rename_default_nodeplugin() ->
|
||||||
|
lists:foreach(fun(Node) ->
|
||||||
|
mnesia:dirty_write(Node#pubsub_node{type = "hometree"})
|
||||||
|
end, mnesia:dirty_match_object(#pubsub_node{type = "default", _ = '_'})).
|
||||||
|
|
||||||
update_state_database(_Host, _ServerHost) ->
|
update_state_database(_Host, _ServerHost) ->
|
||||||
case catch mnesia:table_info(pubsub_state, attributes) of
|
case catch mnesia:table_info(pubsub_state, attributes) of
|
||||||
[stateid, items, affiliation, subscription] ->
|
[stateid, items, affiliation, subscription] ->
|
||||||
|
@ -105,7 +105,8 @@
|
|||||||
string_to_affiliation/1,
|
string_to_affiliation/1,
|
||||||
extended_error/2,
|
extended_error/2,
|
||||||
extended_error/3,
|
extended_error/3,
|
||||||
escape/1
|
escape/1,
|
||||||
|
rename_default_nodeplugin/0
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% API and gen_server callbacks
|
%% API and gen_server callbacks
|
||||||
@ -333,11 +334,9 @@ update_node_database(Host, ServerHost) ->
|
|||||||
end,
|
end,
|
||||||
case mnesia:transaction(FNew) of
|
case mnesia:transaction(FNew) of
|
||||||
{atomic, Result} ->
|
{atomic, Result} ->
|
||||||
?INFO_MSG("Pubsub node tables updated correctly: ~p",
|
?INFO_MSG("Pubsub node tables updated correctly: ~p", [Result]);
|
||||||
[Result]);
|
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("Problem updating Pubsub node tables:~n~p",
|
?ERROR_MSG("Problem updating Pubsub node tables:~n~p", [Reason])
|
||||||
[Reason])
|
|
||||||
end;
|
end;
|
||||||
[nodeid, parentid, type, owners, options] ->
|
[nodeid, parentid, type, owners, options] ->
|
||||||
F = fun({pubsub_node, NodeId, {_, Parent}, Type, Owners, Options}) ->
|
F = fun({pubsub_node, NodeId, {_, Parent}, Type, Owners, Options}) ->
|
||||||
@ -376,11 +375,10 @@ update_node_database(Host, ServerHost) ->
|
|||||||
end,
|
end,
|
||||||
case mnesia:transaction(FNew) of
|
case mnesia:transaction(FNew) of
|
||||||
{atomic, Result} ->
|
{atomic, Result} ->
|
||||||
?INFO_MSG("Pubsub node tables updated correctly: ~p",
|
rename_default_nodeplugin(),
|
||||||
[Result]);
|
?INFO_MSG("Pubsub node tables updated correctly: ~p", [Result]);
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("Problem updating Pubsub node tables:~n~p",
|
?ERROR_MSG("Problem updating Pubsub node tables:~n~p", [Reason])
|
||||||
[Reason])
|
|
||||||
end;
|
end;
|
||||||
[nodeid, id, parent, type, owners, options] ->
|
[nodeid, id, parent, type, owners, options] ->
|
||||||
F = fun({pubsub_node, NodeId, Id, Parent, Type, Owners, Options}) ->
|
F = fun({pubsub_node, NodeId, Id, Parent, Type, Owners, Options}) ->
|
||||||
@ -392,11 +390,18 @@ update_node_database(Host, ServerHost) ->
|
|||||||
owners = Owners,
|
owners = Owners,
|
||||||
options = Options}
|
options = Options}
|
||||||
end,
|
end,
|
||||||
mnesia:transform_table(pubsub_node, F, [nodeid, id, parents, type, owners, options]);
|
mnesia:transform_table(pubsub_node, F, [nodeid, id, parents, type, owners, options]),
|
||||||
|
rename_default_nodeplugin();
|
||||||
_ ->
|
_ ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
rename_default_nodeplugin() ->
|
||||||
|
% lists:foreach(fun(Node) ->
|
||||||
|
% mnesia:dirty_write(Node#pubsub_node{type = "hometree"})
|
||||||
|
% end, mnesia:dirty_match_object(#pubsub_node{type = "default", _ = '_'})).
|
||||||
|
ok.
|
||||||
|
|
||||||
update_state_database(_Host, _ServerHost) ->
|
update_state_database(_Host, _ServerHost) ->
|
||||||
case catch mnesia:table_info(pubsub_state, attributes) of
|
case catch mnesia:table_info(pubsub_state, attributes) of
|
||||||
[stateid, items, affiliation, subscription] ->
|
[stateid, items, affiliation, subscription] ->
|
||||||
@ -2669,16 +2674,23 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
|||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
case lists:member(Owner, node_owners_call(Type, NodeId)) of
|
case lists:member(Owner, node_owners_call(Type, NodeId)) of
|
||||||
true ->
|
true ->
|
||||||
lists:foreach(fun({JID, Subscription, SubId}) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
node_call(Type, set_subscriptions, [NodeId, JID, Subscription, SubId])
|
|
||||||
end, Entities),
|
case node_call(Type, set_subscriptions, [NodeId, JID, Subscription, SubId]) of
|
||||||
{result, []};
|
{error, Err} -> [{error, Err} | Acc];
|
||||||
_ ->
|
_ -> Acc
|
||||||
{error, ?ERR_FORBIDDEN}
|
end
|
||||||
end
|
end, [], Entities),
|
||||||
end,
|
case Result of
|
||||||
|
[] -> {result, []};
|
||||||
|
_ -> {error, ?ERR_NOT_ACCEPTABLE}
|
||||||
|
end;
|
||||||
|
_ ->
|
||||||
|
{error, ?ERR_FORBIDDEN}
|
||||||
|
end
|
||||||
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_, Result}} -> {result, Result};
|
{result, {_, Result}} -> {result, Result};
|
||||||
Other -> Other
|
Other -> Other
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- mod_pubsub.erl 2009-08-20 17:49:22.000000000 +0200
|
--- mod_pubsub.erl 2009-08-25 16:10:58.000000000 +0200
|
||||||
+++ mod_pubsub_odbc.erl 2009-08-21 13:53:33.000000000 +0200
|
+++ mod_pubsub_odbc.erl 2009-08-25 16:12:30.000000000 +0200
|
||||||
@@ -45,7 +45,7 @@
|
@@ -45,7 +45,7 @@
|
||||||
%%% TODO
|
%%% TODO
|
||||||
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
||||||
@ -22,17 +22,15 @@
|
|||||||
|
|
||||||
%% exports for hooks
|
%% exports for hooks
|
||||||
-export([presence_probe/3,
|
-export([presence_probe/3,
|
||||||
@@ -104,7 +104,8 @@
|
@@ -105,6 +105,7 @@
|
||||||
string_to_subscription/1,
|
|
||||||
string_to_affiliation/1,
|
string_to_affiliation/1,
|
||||||
extended_error/2,
|
extended_error/2,
|
||||||
- extended_error/3
|
extended_error/3,
|
||||||
+ extended_error/3,
|
+ escape/1,
|
||||||
+ escape/1
|
rename_default_nodeplugin/0
|
||||||
]).
|
]).
|
||||||
|
|
||||||
%% API and gen_server callbacks
|
@@ -124,7 +125,7 @@
|
||||||
@@ -123,7 +124,7 @@
|
|
||||||
-export([send_loop/1
|
-export([send_loop/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
@ -41,7 +39,7 @@
|
|||||||
-define(PLUGIN_PREFIX, "node_").
|
-define(PLUGIN_PREFIX, "node_").
|
||||||
-define(TREE_PREFIX, "nodetree_").
|
-define(TREE_PREFIX, "nodetree_").
|
||||||
|
|
||||||
@@ -212,8 +213,6 @@
|
@@ -213,8 +214,6 @@
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
ejabberd_router:register_route(Host),
|
ejabberd_router:register_route(Host),
|
||||||
@ -50,7 +48,21 @@
|
|||||||
init_nodes(Host, ServerHost),
|
init_nodes(Host, ServerHost),
|
||||||
State = #state{host = Host,
|
State = #state{host = Host,
|
||||||
server_host = ServerHost,
|
server_host = ServerHost,
|
||||||
@@ -459,17 +458,15 @@
|
@@ -398,9 +397,10 @@
|
||||||
|
end.
|
||||||
|
|
||||||
|
rename_default_nodeplugin() ->
|
||||||
|
- lists:foreach(fun(Node) ->
|
||||||
|
- mnesia:dirty_write(Node#pubsub_node{type = "hometree"})
|
||||||
|
- end, mnesia:dirty_match_object(#pubsub_node{type = "default", _ = '_'})).
|
||||||
|
+% lists:foreach(fun(Node) ->
|
||||||
|
+% mnesia:dirty_write(Node#pubsub_node{type = "hometree"})
|
||||||
|
+% end, mnesia:dirty_match_object(#pubsub_node{type = "default", _ = '_'})).
|
||||||
|
+ ok.
|
||||||
|
|
||||||
|
update_state_database(_Host, _ServerHost) ->
|
||||||
|
case catch mnesia:table_info(pubsub_state, attributes) of
|
||||||
|
@@ -463,17 +463,15 @@
|
||||||
%% for each node From is subscribed to
|
%% for each node From is subscribed to
|
||||||
%% and if the node is so configured, send the last published item to From
|
%% and if the node is so configured, send the last published item to From
|
||||||
lists:foreach(fun(PType) ->
|
lists:foreach(fun(PType) ->
|
||||||
@ -74,7 +86,7 @@
|
|||||||
true ->
|
true ->
|
||||||
% resource not concerned about that subscription
|
% resource not concerned about that subscription
|
||||||
ok
|
ok
|
||||||
@@ -792,10 +789,10 @@
|
@@ -796,10 +794,10 @@
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
||||||
lists:foreach(fun
|
lists:foreach(fun
|
||||||
({Node, subscribed, _, JID}) ->
|
({Node, subscribed, _, JID}) ->
|
||||||
@ -87,7 +99,7 @@
|
|||||||
true ->
|
true ->
|
||||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||||
false ->
|
false ->
|
||||||
@@ -909,7 +906,8 @@
|
@@ -913,7 +911,8 @@
|
||||||
sub_el = SubEl} = IQ ->
|
sub_el = SubEl} = IQ ->
|
||||||
{xmlelement, _, QAttrs, _} = SubEl,
|
{xmlelement, _, QAttrs, _} = SubEl,
|
||||||
Node = xml:get_attr_s("node", QAttrs),
|
Node = xml:get_attr_s("node", QAttrs),
|
||||||
@ -97,7 +109,7 @@
|
|||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
jlib:iq_to_xml(
|
jlib:iq_to_xml(
|
||||||
IQ#iq{type = result,
|
IQ#iq{type = result,
|
||||||
@@ -1014,7 +1012,7 @@
|
@@ -1018,7 +1017,7 @@
|
||||||
[] ->
|
[] ->
|
||||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||||
_ ->
|
_ ->
|
||||||
@ -106,7 +118,7 @@
|
|||||||
{result, []} -> ["collection"];
|
{result, []} -> ["collection"];
|
||||||
{result, _} -> ["leaf", "collection"];
|
{result, _} -> ["leaf", "collection"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -1030,8 +1028,9 @@
|
@@ -1034,8 +1033,9 @@
|
||||||
[];
|
[];
|
||||||
true ->
|
true ->
|
||||||
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
|
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
|
||||||
@ -118,7 +130,7 @@
|
|||||||
end, features(Type))]
|
end, features(Type))]
|
||||||
end,
|
end,
|
||||||
%% TODO: add meta-data info (spec section 5.4)
|
%% TODO: add meta-data info (spec section 5.4)
|
||||||
@@ -1059,14 +1058,15 @@
|
@@ -1063,14 +1063,15 @@
|
||||||
{xmlelement, "feature", [{"var", ?NS_DISCO_ITEMS}], []},
|
{xmlelement, "feature", [{"var", ?NS_DISCO_ITEMS}], []},
|
||||||
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
|
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
|
||||||
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
|
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
|
||||||
@ -137,7 +149,7 @@
|
|||||||
{result, lists:map(
|
{result, lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||||
SN = node_to_string(SubNode),
|
SN = node_to_string(SubNode),
|
||||||
@@ -1076,7 +1076,7 @@
|
@@ -1080,7 +1081,7 @@
|
||||||
{"node", SN},
|
{"node", SN},
|
||||||
{"name", RN}], []}
|
{"name", RN}], []}
|
||||||
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
||||||
@ -146,7 +158,7 @@
|
|||||||
case string:tokens(Item, "!") of
|
case string:tokens(Item, "!") of
|
||||||
[_SNode, _ItemID] ->
|
[_SNode, _ItemID] ->
|
||||||
{result, []};
|
{result, []};
|
||||||
@@ -1088,9 +1088,9 @@
|
@@ -1092,9 +1093,9 @@
|
||||||
%% TODO That is, remove name attribute (or node?, please check for 2.1)
|
%% TODO That is, remove name attribute (or node?, please check for 2.1)
|
||||||
Action =
|
Action =
|
||||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
@ -158,7 +170,7 @@
|
|||||||
end,
|
end,
|
||||||
Nodes = lists:map(
|
Nodes = lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||||
@@ -1106,7 +1106,7 @@
|
@@ -1110,7 +1111,7 @@
|
||||||
{xmlelement, "item", [{"jid", Host}, {"node", SN},
|
{xmlelement, "item", [{"jid", Host}, {"node", SN},
|
||||||
{"name", Name}], []}
|
{"name", Name}], []}
|
||||||
end, NodeItems),
|
end, NodeItems),
|
||||||
@ -167,7 +179,7 @@
|
|||||||
end,
|
end,
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {_, Result}} -> {result, Result};
|
{result, {_, Result}} -> {result, Result};
|
||||||
@@ -1238,7 +1238,8 @@
|
@@ -1242,7 +1243,8 @@
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, [], xml:remove_cdata(Els)),
|
end, [], xml:remove_cdata(Els)),
|
||||||
@ -177,7 +189,7 @@
|
|||||||
{get, "subscriptions"} ->
|
{get, "subscriptions"} ->
|
||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, "affiliations"} ->
|
{get, "affiliations"} ->
|
||||||
@@ -1261,7 +1262,10 @@
|
@@ -1265,7 +1267,10 @@
|
||||||
|
|
||||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||||
{xmlelement, _, _, SubEls} = SubEl,
|
{xmlelement, _, _, SubEls} = SubEl,
|
||||||
@ -189,7 +201,7 @@
|
|||||||
case Action of
|
case Action of
|
||||||
[{xmlelement, Name, Attrs, Els}] ->
|
[{xmlelement, Name, Attrs, Els}] ->
|
||||||
Node = case Host of
|
Node = case Host of
|
||||||
@@ -1387,7 +1391,8 @@
|
@@ -1391,7 +1396,8 @@
|
||||||
_ -> []
|
_ -> []
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -199,7 +211,7 @@
|
|||||||
sync_dirty) of
|
sync_dirty) of
|
||||||
{result, Res} -> Res;
|
{result, Res} -> Res;
|
||||||
Err -> Err
|
Err -> Err
|
||||||
@@ -1431,7 +1436,7 @@
|
@@ -1435,7 +1441,7 @@
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
@ -208,7 +220,7 @@
|
|||||||
Lang = "en", %% TODO fix
|
Lang = "en", %% TODO fix
|
||||||
Stanza = {xmlelement, "message",
|
Stanza = {xmlelement, "message",
|
||||||
[],
|
[],
|
||||||
@@ -1460,7 +1465,7 @@
|
@@ -1464,7 +1470,7 @@
|
||||||
[{xmlelement, "value", [], [{xmlcdata, "false"}]}]}]}]},
|
[{xmlelement, "value", [], [{xmlcdata, "false"}]}]}]}]},
|
||||||
lists:foreach(fun(Owner) ->
|
lists:foreach(fun(Owner) ->
|
||||||
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(Owner), Stanza}
|
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(Owner), Stanza}
|
||||||
@ -217,7 +229,7 @@
|
|||||||
|
|
||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
{xmlelement, _Name, _Attrs, Els} = Packet,
|
{xmlelement, _Name, _Attrs, Els} = Packet,
|
||||||
@@ -1527,8 +1532,8 @@
|
@@ -1531,8 +1537,8 @@
|
||||||
"true" -> true;
|
"true" -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end,
|
end,
|
||||||
@ -228,7 +240,7 @@
|
|||||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||||
if
|
if
|
||||||
not IsApprover ->
|
not IsApprover ->
|
||||||
@@ -1714,7 +1719,7 @@
|
@@ -1718,7 +1724,7 @@
|
||||||
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||||
[{xmlelement, "create", nodeAttr(Node),
|
[{xmlelement, "create", nodeAttr(Node),
|
||||||
[]}]}],
|
[]}]}],
|
||||||
@ -237,7 +249,7 @@
|
|||||||
{result, {Result, broadcast}} ->
|
{result, {Result, broadcast}} ->
|
||||||
%%Lang = "en", %% TODO: fix
|
%%Lang = "en", %% TODO: fix
|
||||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||||
@@ -1826,7 +1831,7 @@
|
@@ -1830,7 +1836,7 @@
|
||||||
error -> {"", "", ""};
|
error -> {"", "", ""};
|
||||||
J -> jlib:jid_tolower(J)
|
J -> jlib:jid_tolower(J)
|
||||||
end,
|
end,
|
||||||
@ -246,7 +258,7 @@
|
|||||||
Features = features(Type),
|
Features = features(Type),
|
||||||
SubscribeFeature = lists:member("subscribe", Features),
|
SubscribeFeature = lists:member("subscribe", Features),
|
||||||
OptionsFeature = lists:member("subscription-options", Features),
|
OptionsFeature = lists:member("subscription-options", Features),
|
||||||
@@ -1845,9 +1850,13 @@
|
@@ -1849,9 +1855,13 @@
|
||||||
{"", "", ""} ->
|
{"", "", ""} ->
|
||||||
{false, false};
|
{false, false};
|
||||||
_ ->
|
_ ->
|
||||||
@ -263,7 +275,7 @@
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2170,7 +2179,7 @@
|
@@ -2174,7 +2184,7 @@
|
||||||
%% <p>The permission are not checked in this function.</p>
|
%% <p>The permission are not checked in this function.</p>
|
||||||
%% @todo We probably need to check that the user doing the query has the right
|
%% @todo We probably need to check that the user doing the query has the right
|
||||||
%% to read the items.
|
%% to read the items.
|
||||||
@ -272,7 +284,7 @@
|
|||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> ?MAXITEMS;
|
SMaxItems == "" -> ?MAXITEMS;
|
||||||
@@ -2209,11 +2218,11 @@
|
@@ -2213,11 +2223,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
@ -286,7 +298,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2226,7 +2235,8 @@
|
@@ -2230,7 +2240,8 @@
|
||||||
%% number of items sent to MaxItems:
|
%% number of items sent to MaxItems:
|
||||||
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
{result, [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||||
[{xmlelement, "items", nodeAttr(Node),
|
[{xmlelement, "items", nodeAttr(Node),
|
||||||
@ -296,7 +308,7 @@
|
|||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2258,15 +2268,22 @@
|
@@ -2262,15 +2273,22 @@
|
||||||
%% @doc <p>Resend the items of a node to the user.</p>
|
%% @doc <p>Resend the items of a node to the user.</p>
|
||||||
%% @todo use cache-last-item feature
|
%% @todo use cache-last-item feature
|
||||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||||
@ -325,7 +337,7 @@
|
|||||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||||
{result, []} ->
|
{result, []} ->
|
||||||
@@ -2384,29 +2401,12 @@
|
@@ -2388,29 +2406,12 @@
|
||||||
error ->
|
error ->
|
||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
@ -358,18 +370,18 @@
|
|||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2668,8 +2668,8 @@
|
@@ -2672,8 +2673,8 @@
|
||||||
error ->
|
error ->
|
||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
- Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
|
- Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
|
||||||
- case lists:member(Owner, Owners) of
|
- case lists:member(Owner, Owners) of
|
||||||
+ Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
+ Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
+ case lists:member(Owner, node_owners_call(Type, NodeId)) of
|
+ case lists:member(Owner, node_owners_call(Type, NodeId)) of
|
||||||
true ->
|
true ->
|
||||||
lists:foreach(fun({JID, Subscription, SubId}) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
node_call(Type, set_subscriptions, [NodeId, JID, Subscription, SubId])
|
|
||||||
@@ -3159,6 +3159,30 @@
|
@@ -3170,6 +3171,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -400,7 +412,7 @@
|
|||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3532,7 +3556,13 @@
|
@@ -3543,7 +3568,13 @@
|
||||||
tree_action(Host, Function, Args) ->
|
tree_action(Host, Function, Args) ->
|
||||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||||
@ -415,7 +427,7 @@
|
|||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3552,13 +3582,13 @@
|
@@ -3563,13 +3594,13 @@
|
||||||
|
|
||||||
node_action(Host, Type, Function, Args) ->
|
node_action(Host, Type, Function, Args) ->
|
||||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||||
@ -431,7 +443,7 @@
|
|||||||
case tree_call(Host, get_node, [Host, Node]) of
|
case tree_call(Host, get_node, [Host, Node]) of
|
||||||
N when is_record(N, pubsub_node) ->
|
N when is_record(N, pubsub_node) ->
|
||||||
case Action(N) of
|
case Action(N) of
|
||||||
@@ -3571,8 +3601,14 @@
|
@@ -3582,8 +3613,14 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
@ -448,7 +460,7 @@
|
|||||||
{result, Result} -> {result, Result};
|
{result, Result} -> {result, Result};
|
||||||
{error, Error} -> {error, Error};
|
{error, Error} -> {error, Error};
|
||||||
{atomic, {result, Result}} -> {result, Result};
|
{atomic, {result, Result}} -> {result, Result};
|
||||||
@@ -3580,6 +3616,15 @@
|
@@ -3591,6 +3628,15 @@
|
||||||
{aborted, Reason} ->
|
{aborted, Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
@ -464,7 +476,7 @@
|
|||||||
{'EXIT', Reason} ->
|
{'EXIT', Reason} ->
|
||||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
@@ -3588,6 +3633,17 @@
|
@@ -3599,6 +3645,17 @@
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user