24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-14 22:00:16 +02:00

Fix disco on root node, add commands to disco (thanks to Brian Cully)(EJAB-1094)

SVN Revision: 2722
This commit is contained in:
Badlop 2009-11-04 19:54:15 +00:00
parent 3930715712
commit 1a5eb4f73d
3 changed files with 112 additions and 39 deletions

View File

@ -1030,6 +1030,18 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
end end
end. end.
command_disco_info(_Host, <<?NS_COMMANDS>>, _From) ->
IdentityEl = {xmlelement, "identity", [{"category", "automation"},
{"type", "command-list"}],
[]},
{result, [IdentityEl]};
command_disco_info(_Host, <<?NS_PUBSUB_GET_PENDING>>, _From) ->
IdentityEl = {xmlelement, "identity", [{"category", "automation"},
{"type", "command-node"}],
[]},
FeaturesEl = {xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
{result, [IdentityEl, FeaturesEl]}.
node_disco_info(Host, Node, From) -> node_disco_info(Host, Node, From) ->
node_disco_info(Host, Node, From, true, true). node_disco_info(Host, Node, From, true, true).
node_disco_identity(Host, Node, From) -> node_disco_identity(Host, Node, From) ->
@ -1092,10 +1104,15 @@ iq_disco_info(Host, SNode, From, Lang) ->
{xmlelement, "feature", [{"var", ?NS_DISCO_INFO}], []}, {xmlelement, "feature", [{"var", ?NS_DISCO_INFO}], []},
{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_COMMANDS}], []},
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++ {xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
lists:map(fun(Feature) -> lists:map(fun(Feature) ->
{xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++Feature}], []} {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++Feature}], []}
end, features(Host, Node))}; end, features(Host, Node))};
<<?NS_COMMANDS>> ->
command_disco_info(Host, Node, From);
<<?NS_PUBSUB_GET_PENDING>> ->
command_disco_info(Host, Node, From);
_ -> _ ->
node_disco_info(Host, Node, From) node_disco_info(Host, Node, From)
end. end.
@ -1112,6 +1129,13 @@ iq_disco_items(Host, [], From) ->
Other -> Other ->
Other Other
end; end;
iq_disco_items(Host, ?NS_COMMANDS, _From) ->
%% TODO: support localization of this string
CommandItems = [{xmlelement, "item", [{"jid", Host}, {"node", ?NS_PUBSUB_GET_PENDING}, {"name", "Get Pending"}], []}],
{result, CommandItems};
iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From) ->
CommandItems = [],
{result, CommandItems};
iq_disco_items(Host, Item, From) -> iq_disco_items(Host, Item, From) ->
case string:tokens(Item, "!") of case string:tokens(Item, "!") of
[_SNode, _ItemID] -> [_SNode, _ItemID] ->
@ -1373,6 +1397,13 @@ adhoc_request(Host, _ServerHost, Owner,
Error -> Error ->
Error Error
end; end;
adhoc_request(_Host, _ServerHost, _Owner, #adhoc_request{action = "cancel"},
_Access, _Plugins) ->
#adhoc_response{status = canceled};
adhoc_request(Host, ServerHost, Owner, #adhoc_request{action = []} = R,
Access, Plugins) ->
adhoc_request(Host, ServerHost, Owner, R#adhoc_request{action = "execute"},
Access, Plugins);
adhoc_request(_Host, _ServerHost, _Owner, Other, _Access, _Plugins) -> adhoc_request(_Host, _ServerHost, _Owner, Other, _Access, _Plugins) ->
?DEBUG("Couldn't process ad hoc command:~n~p", [Other]), ?DEBUG("Couldn't process ad hoc command:~n~p", [Other]),
{error, ?ERR_ITEM_NOT_FOUND}. {error, ?ERR_ITEM_NOT_FOUND}.
@ -3589,7 +3620,7 @@ features(Type) ->
{'EXIT', {undef, _}} -> []; {'EXIT', {undef, _}} -> [];
Result -> Result Result -> Result
end. end.
features(Host, []) -> features(Host, <<>>) ->
lists:usort(lists:foldl(fun(Plugin, Acc) -> lists:usort(lists:foldl(fun(Plugin, Acc) ->
Acc ++ features(Plugin) Acc ++ features(Plugin)
end, [], plugins(Host))); end, [], plugins(Host)));

View File

@ -834,6 +834,18 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
end end
end. end.
command_disco_info(_Host, <<?NS_COMMANDS>>, _From) ->
IdentityEl = {xmlelement, "identity", [{"category", "automation"},
{"type", "command-list"}],
[]},
{result, [IdentityEl]};
command_disco_info(_Host, <<?NS_PUBSUB_GET_PENDING>>, _From) ->
IdentityEl = {xmlelement, "identity", [{"category", "automation"},
{"type", "command-node"}],
[]},
FeaturesEl = {xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
{result, [IdentityEl, FeaturesEl]}.
node_disco_info(Host, Node, From) -> node_disco_info(Host, Node, From) ->
node_disco_info(Host, Node, From, true, true). node_disco_info(Host, Node, From, true, true).
node_disco_identity(Host, Node, From) -> node_disco_identity(Host, Node, From) ->
@ -897,11 +909,16 @@ iq_disco_info(Host, SNode, From, Lang) ->
{xmlelement, "feature", [{"var", ?NS_DISCO_INFO}], []}, {xmlelement, "feature", [{"var", ?NS_DISCO_INFO}], []},
{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_COMMANDS}], []},
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++ {xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
lists:map(fun lists:map(fun
("rsm")-> {xmlelement, "feature", [{"var", ?NS_RSM}], []}; ("rsm")-> {xmlelement, "feature", [{"var", ?NS_RSM}], []};
(T) -> {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++T}], []} (T) -> {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++T}], []}
end, features(Host, Node))}; end, features(Host, Node))};
<<?NS_COMMANDS>> ->
command_disco_info(Host, Node, From);
<<?NS_PUBSUB_GET_PENDING>> ->
command_disco_info(Host, Node, From);
_ -> _ ->
node_disco_info(Host, Node, From) node_disco_info(Host, Node, From)
end. end.
@ -918,6 +935,13 @@ iq_disco_items(Host, [], From, _RSM) ->
Other -> Other ->
Other Other
end; end;
iq_disco_items(Host, ?NS_COMMANDS, _From, _RSM) ->
%% TODO: support localization of this string
CommandItems = [{xmlelement, "item", [{"jid", Host}, {"node", ?NS_PUBSUB_GET_PENDING}, {"name", "Get Pending"}], []}],
{result, CommandItems};
iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From, _RSM) ->
CommandItems = [],
{result, CommandItems};
iq_disco_items(Host, Item, From, RSM) -> iq_disco_items(Host, Item, From, RSM) ->
case string:tokens(Item, "!") of case string:tokens(Item, "!") of
[_SNode, _ItemID] -> [_SNode, _ItemID] ->
@ -1182,6 +1206,13 @@ adhoc_request(Host, _ServerHost, Owner,
Error -> Error ->
Error Error
end; end;
adhoc_request(_Host, _ServerHost, _Owner, #adhoc_request{action = "cancel"},
_Access, _Plugins) ->
#adhoc_response{status = canceled};
adhoc_request(Host, ServerHost, Owner, #adhoc_request{action = []} = R,
Access, Plugins) ->
adhoc_request(Host, ServerHost, Owner, R#adhoc_request{action = "execute"},
Access, Plugins);
adhoc_request(_Host, _ServerHost, _Owner, Other, _Access, _Plugins) -> adhoc_request(_Host, _ServerHost, _Owner, Other, _Access, _Plugins) ->
?DEBUG("Couldn't process ad hoc command:~n~p", [Other]), ?DEBUG("Couldn't process ad hoc command:~n~p", [Other]),
{error, ?ERR_ITEM_NOT_FOUND}. {error, ?ERR_ITEM_NOT_FOUND}.
@ -3422,7 +3453,7 @@ features(Type) ->
{'EXIT', {undef, _}} -> []; {'EXIT', {undef, _}} -> [];
Result -> Result Result -> Result
end. end.
features(Host, []) -> features(Host, <<>>) ->
lists:usort(lists:foldl(fun(Plugin, Acc) -> lists:usort(lists:foldl(fun(Plugin, Acc) ->
Acc ++ features(Plugin) Acc ++ features(Plugin)
end, [], plugins(Host))); end, [], plugins(Host)));

View File

@ -1,5 +1,5 @@
--- mod_pubsub.erl 2009-11-04 20:38:09.000000000 +0100 --- mod_pubsub.erl 2009-11-04 20:40:18.000000000 +0100
+++ mod_pubsub_odbc.erl 2009-11-04 20:39:02.000000000 +0100 +++ mod_pubsub_odbc.erl 2009-11-04 20:40:18.000000000 +0100
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see %%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
%%% XEP-0060 section 12.18. %%% XEP-0060 section 12.18.
@ -307,7 +307,7 @@
{result, IQRes} -> {result, IQRes} ->
jlib:iq_to_xml( jlib:iq_to_xml(
IQ#iq{type = result, IQ#iq{type = result,
@@ -1048,7 +852,7 @@ @@ -1060,7 +864,7 @@
[] -> [] ->
["leaf"]; %% No sub-nodes: it's a leaf node ["leaf"]; %% No sub-nodes: it's a leaf node
_ -> _ ->
@ -316,7 +316,7 @@
{result, []} -> ["collection"]; {result, []} -> ["collection"];
{result, _} -> ["leaf", "collection"]; {result, _} -> ["leaf", "collection"];
_ -> [] _ -> []
@@ -1064,8 +868,9 @@ @@ -1076,8 +880,9 @@
[]; [];
true -> true ->
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} | [{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
@ -328,9 +328,9 @@
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)
@@ -1093,14 +898,15 @@ @@ -1106,8 +911,9 @@
{xmlelement, "feature", [{"var", ?NS_DISCO_ITEMS}], []},
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []}, {xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
{xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++ {xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
- lists:map(fun(Feature) -> - lists:map(fun(Feature) ->
- {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++Feature}], []} - {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++Feature}], []}
@ -338,7 +338,9 @@
+ ("rsm")-> {xmlelement, "feature", [{"var", ?NS_RSM}], []}; + ("rsm")-> {xmlelement, "feature", [{"var", ?NS_RSM}], []};
+ (T) -> {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++T}], []} + (T) -> {xmlelement, "feature", [{"var", ?NS_PUBSUB++"#"++T}], []}
end, features(Host, Node))}; end, features(Host, Node))};
_ -> <<?NS_COMMANDS>> ->
command_disco_info(Host, Node, From);
@@ -1117,7 +923,7 @@
node_disco_info(Host, Node, From) node_disco_info(Host, Node, From)
end. end.
@ -347,16 +349,25 @@
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
Nodes when is_list(Nodes) -> Nodes when is_list(Nodes) ->
{result, lists:map( {result, lists:map(
@@ -1112,7 +918,7 @@ @@ -1129,14 +935,14 @@
Other -> Other ->
Other Other
end; end;
-iq_disco_items(Host, ?NS_COMMANDS, _From) ->
+iq_disco_items(Host, ?NS_COMMANDS, _From, _RSM) ->
%% TODO: support localization of this string
CommandItems = [{xmlelement, "item", [{"jid", Host}, {"node", ?NS_PUBSUB_GET_PENDING}, {"name", "Get Pending"}], []}],
{result, CommandItems};
-iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From) ->
+iq_disco_items(_Host, ?NS_PUBSUB_GET_PENDING, _From, _RSM) ->
CommandItems = [],
{result, CommandItems};
-iq_disco_items(Host, Item, From) -> -iq_disco_items(Host, Item, From) ->
+iq_disco_items(Host, Item, From, RSM) -> +iq_disco_items(Host, Item, From, RSM) ->
case string:tokens(Item, "!") of case string:tokens(Item, "!") of
[_SNode, _ItemID] -> [_SNode, _ItemID] ->
{result, []}; {result, []};
@@ -1120,10 +926,10 @@ @@ -1144,10 +950,10 @@
Node = string_to_node(SNode), Node = string_to_node(SNode),
Action = Action =
fun(#pubsub_node{type = Type, id = NodeId}) -> fun(#pubsub_node{type = Type, id = NodeId}) ->
@ -370,7 +381,7 @@
end, end,
Nodes = lists:map( Nodes = lists:map(
fun(#pubsub_node{nodeid = {_, SubNode}}) -> fun(#pubsub_node{nodeid = {_, SubNode}}) ->
@@ -1136,7 +942,7 @@ @@ -1160,7 +966,7 @@
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]), {result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
{xmlelement, "item", [{"jid", Host}, {"name", Name}], []} {xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
end, NodeItems), end, NodeItems),
@ -379,7 +390,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};
@@ -1265,7 +1071,8 @@ @@ -1289,7 +1095,8 @@
(_, Acc) -> (_, Acc) ->
Acc Acc
end, [], xml:remove_cdata(Els)), end, [], xml:remove_cdata(Els)),
@ -389,7 +400,7 @@
{get, "subscriptions"} -> {get, "subscriptions"} ->
get_subscriptions(Host, Node, From, Plugins); get_subscriptions(Host, Node, From, Plugins);
{get, "affiliations"} -> {get, "affiliations"} ->
@@ -1288,7 +1095,9 @@ @@ -1312,7 +1119,9 @@
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) -> iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
{xmlelement, _, _, SubEls} = SubEl, {xmlelement, _, _, SubEls} = SubEl,
@ -400,7 +411,7 @@
case Action of case Action of
[{xmlelement, Name, Attrs, Els}] -> [{xmlelement, Name, Attrs, Els}] ->
Node = string_to_node(xml:get_attr_s("node", Attrs)), Node = string_to_node(xml:get_attr_s("node", Attrs)),
@@ -1411,7 +1220,8 @@ @@ -1442,7 +1251,8 @@
_ -> [] _ -> []
end end
end, end,
@ -410,7 +421,7 @@
sync_dirty) of sync_dirty) of
{result, Res} -> Res; {result, Res} -> Res;
Err -> Err Err -> Err
@@ -1450,7 +1260,7 @@ @@ -1481,7 +1291,7 @@
%%% authorization handling %%% authorization handling
@ -419,7 +430,7 @@
Lang = "en", %% TODO fix Lang = "en", %% TODO fix
Stanza = {xmlelement, "message", Stanza = {xmlelement, "message",
[], [],
@@ -1479,7 +1289,7 @@ @@ -1510,7 +1320,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}
@ -428,7 +439,7 @@
find_authorization_response(Packet) -> find_authorization_response(Packet) ->
{xmlelement, _Name, _Attrs, Els} = Packet, {xmlelement, _Name, _Attrs, Els} = Packet,
@@ -1543,8 +1353,8 @@ @@ -1574,8 +1384,8 @@
"true" -> true; "true" -> true;
_ -> false _ -> false
end, end,
@ -439,7 +450,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 ->
@@ -1735,7 +1545,7 @@ @@ -1766,7 +1576,7 @@
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}], Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
[{xmlelement, "create", nodeAttr(Node), [{xmlelement, "create", nodeAttr(Node),
[]}]}], []}]}],
@ -448,7 +459,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)),
@@ -1843,7 +1653,7 @@ @@ -1874,7 +1684,7 @@
%%<li>The node does not exist.</li> %%<li>The node does not exist.</li>
%%</ul> %%</ul>
subscribe_node(Host, Node, From, JID, Configuration) -> subscribe_node(Host, Node, From, JID, Configuration) ->
@ -457,7 +468,7 @@
{result, GoodSubOpts} -> GoodSubOpts; {result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid _ -> invalid
end, end,
@@ -1851,7 +1661,7 @@ @@ -1882,7 +1692,7 @@
error -> {"", "", ""}; error -> {"", "", ""};
J -> jlib:jid_tolower(J) J -> jlib:jid_tolower(J)
end, end,
@ -466,7 +477,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),
@@ -1870,9 +1680,13 @@ @@ -1901,9 +1711,13 @@
{"", "", ""} -> {"", "", ""} ->
{false, false}; {false, false};
_ -> _ ->
@ -483,7 +494,7 @@
end end
end, end,
if if
@@ -2203,7 +2017,7 @@ @@ -2234,7 +2048,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.
@ -492,7 +503,7 @@
MaxItems = MaxItems =
if if
SMaxItems == "" -> get_max_items_node(Host); SMaxItems == "" -> get_max_items_node(Host);
@@ -2242,11 +2056,11 @@ @@ -2273,11 +2087,11 @@
node_call(Type, get_items, node_call(Type, get_items,
[NodeId, From, [NodeId, From,
AccessModel, PresenceSubscription, RosterGroup, AccessModel, PresenceSubscription, RosterGroup,
@ -506,7 +517,7 @@
SendItems = case ItemIDs of SendItems = case ItemIDs of
[] -> [] ->
Items; Items;
@@ -2259,7 +2073,8 @@ @@ -2290,7 +2104,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),
@ -516,7 +527,7 @@
Error -> Error ->
Error Error
end end
@@ -2291,16 +2106,27 @@ @@ -2322,16 +2137,27 @@
%% @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) ->
@ -550,7 +561,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, []} ->
@@ -2426,29 +2252,12 @@ @@ -2457,29 +2283,12 @@
error -> error ->
{error, ?ERR_BAD_REQUEST}; {error, ?ERR_BAD_REQUEST};
_ -> _ ->
@ -583,7 +594,7 @@
end, Entities), end, Entities),
{result, []}; {result, []};
_ -> _ ->
@@ -2501,11 +2310,11 @@ @@ -2532,11 +2341,11 @@
end. end.
read_sub(Subscriber, Node, NodeID, SubID, Lang) -> read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
@ -597,7 +608,7 @@
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)}, OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
{"subid", SubID}|nodeAttr(Node)], {"subid", SubID}|nodeAttr(Node)],
[XdataEl]}, [XdataEl]},
@@ -2531,7 +2340,7 @@ @@ -2562,7 +2371,7 @@
end. end.
set_options_helper(Configuration, JID, NodeID, SubID, Type) -> set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
@ -606,7 +617,7 @@
{result, GoodSubOpts} -> GoodSubOpts; {result, GoodSubOpts} -> GoodSubOpts;
_ -> invalid _ -> invalid
end, end,
@@ -2560,7 +2369,7 @@ @@ -2591,7 +2400,7 @@
write_sub(_Subscriber, _NodeID, _SubID, invalid) -> write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")}; {error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
write_sub(Subscriber, NodeID, SubID, Options) -> write_sub(Subscriber, NodeID, SubID, Options) ->
@ -615,7 +626,7 @@
{error, notfound} -> {error, notfound} ->
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; {error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
{result, _} -> {result, _} ->
@@ -2728,8 +2537,8 @@ @@ -2759,8 +2568,8 @@
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]}, {"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
ejabberd_router ! {route, service_jid(Host), jlib:make_jid(JID), Stanza} ejabberd_router ! {route, service_jid(Host), jlib:make_jid(JID), Stanza}
end, end,
@ -626,7 +637,7 @@
true -> true ->
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) -> Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
@@ -3013,7 +2822,7 @@ @@ -3044,7 +2853,7 @@
{Depth, [{N, get_node_subs(N)} || N <- Nodes]} {Depth, [{N, get_node_subs(N)} || N <- Nodes]}
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))} end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
end, end,
@ -635,7 +646,7 @@
{result, CollSubs} -> CollSubs; {result, CollSubs} -> CollSubs;
_ -> [] _ -> []
end. end.
@@ -3027,9 +2836,9 @@ @@ -3058,9 +2867,9 @@
get_options_for_subs(NodeID, Subs) -> get_options_for_subs(NodeID, Subs) ->
lists:foldl(fun({JID, subscribed, SubID}, Acc) -> lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
@ -647,7 +658,7 @@
_ -> Acc _ -> Acc
end; end;
(_, Acc) -> (_, Acc) ->
@@ -3227,6 +3036,30 @@ @@ -3258,6 +3067,30 @@
Result Result
end. end.
@ -678,7 +689,7 @@
%% @spec (Host, Options) -> MaxItems %% @spec (Host, Options) -> MaxItems
%% Host = host() %% Host = host()
%% Options = [Option] %% Options = [Option]
@@ -3613,7 +3446,13 @@ @@ -3644,7 +3477,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,
@ -693,7 +704,7 @@
%% @doc <p>node plugin call.</p> %% @doc <p>node plugin call.</p>
node_call(Type, Function, Args) -> node_call(Type, Function, Args) ->
@@ -3633,13 +3472,13 @@ @@ -3664,13 +3503,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]),
@ -709,7 +720,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
@@ -3652,8 +3491,14 @@ @@ -3683,8 +3522,14 @@
end end
end, Trans). end, Trans).
@ -726,7 +737,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};
@@ -3661,6 +3506,15 @@ @@ -3692,6 +3537,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};
@ -742,7 +753,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};
@@ -3669,6 +3523,17 @@ @@ -3700,6 +3554,17 @@
{error, ?ERR_INTERNAL_SERVER_ERROR} {error, ?ERR_INTERNAL_SERVER_ERROR}
end. end.