mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Fix disco on root node, add commands to disco (thanks to Brian Cully)(EJAB-1094)
SVN Revision: 2726
This commit is contained in:
parent
5138a9709e
commit
ff338a0a62
@ -1052,6 +1052,21 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
command_disco_info(_Host, ?NS_ADHOC_b, _From) ->
|
||||||
|
IdentityEl =
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
|
attrs = [?XMLATTR('category', <<"automation">>),
|
||||||
|
?XMLATTR('type', <<"command-list">>)]},
|
||||||
|
{result, [IdentityEl]};
|
||||||
|
command_disco_info(_Host, <<?NS_PUBSUB_GET_PENDING>>, _From) ->
|
||||||
|
IdentityEl =
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
|
attrs = [?XMLATTR('category', <<"automation">>),
|
||||||
|
?XMLATTR('type', <<"command-node">>)]},
|
||||||
|
FeaturesEl = #xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
|
attrs = [?XMLATTR('var', ?NS_ADHOC)]},
|
||||||
|
{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) ->
|
||||||
@ -1114,10 +1129,15 @@ iq_disco_info(Host, SNode, From, Lang) ->
|
|||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||||
lists:map(fun(Feature) ->
|
lists:map(fun(Feature) ->
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
||||||
end, features(Host, Node))};
|
end, features(Host, Node))};
|
||||||
|
?NS_ADHOC_b ->
|
||||||
|
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.
|
||||||
@ -1135,6 +1155,18 @@ iq_disco_items(Host, [], From) ->
|
|||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end;
|
end;
|
||||||
|
iq_disco_items(Host, ?NS_ADHOC_s, _From) ->
|
||||||
|
%% TODO: support localization of this string
|
||||||
|
CommandItems = [
|
||||||
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||||
|
attrs = [?XMLATTR('jid', Host),
|
||||||
|
?XMLATTR('node', ?NS_PUBSUB_GET_PENDING),
|
||||||
|
?XMLATTR('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] ->
|
||||||
@ -1398,6 +1430,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, exmpp_stanza:error(?NS_JABBER_CLIENT, 'item-not-found')}.
|
{error, exmpp_stanza:error(?NS_JABBER_CLIENT, 'item-not-found')}.
|
||||||
@ -3653,7 +3692,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)));
|
||||||
|
@ -857,6 +857,21 @@ do_route(ServerHost, Access, Plugins, Host, From, To, Packet) ->
|
|||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
command_disco_info(_Host, ?NS_ADHOC_b, _From) ->
|
||||||
|
IdentityEl =
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
|
attrs = [?XMLATTR('category', <<"automation">>),
|
||||||
|
?XMLATTR('type', <<"command-list">>)]},
|
||||||
|
{result, [IdentityEl]};
|
||||||
|
command_disco_info(_Host, <<?NS_PUBSUB_GET_PENDING>>, _From) ->
|
||||||
|
IdentityEl =
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'identity',
|
||||||
|
attrs = [?XMLATTR('category', <<"automation">>),
|
||||||
|
?XMLATTR('type', <<"command-node">>)]},
|
||||||
|
FeaturesEl = #xmlel{ns = ?NS_DISCO_INFO, name = 'feature',
|
||||||
|
attrs = [?XMLATTR('var', ?NS_ADHOC)]},
|
||||||
|
{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) ->
|
||||||
@ -920,11 +935,16 @@ iq_disco_info(Host, SNode, From, Lang) ->
|
|||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_INFO_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||||
lists:map(fun
|
lists:map(fun
|
||||||
("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]};
|
("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]};
|
||||||
(Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
(Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
||||||
end, features(Host, Node))};
|
end, features(Host, Node))};
|
||||||
|
?NS_ADHOC_b ->
|
||||||
|
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.
|
||||||
@ -942,6 +962,18 @@ iq_disco_items(Host, [], From, _RSM) ->
|
|||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end;
|
end;
|
||||||
|
iq_disco_items(Host, ?NS_ADHOC_s, _From, _RSM) ->
|
||||||
|
%% TODO: support localization of this string
|
||||||
|
CommandItems = [
|
||||||
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||||
|
attrs = [?XMLATTR('jid', Host),
|
||||||
|
?XMLATTR('node', ?NS_PUBSUB_GET_PENDING),
|
||||||
|
?XMLATTR('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] ->
|
||||||
@ -1208,6 +1240,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, exmpp_stanza:error(?NS_JABBER_CLIENT, 'item-not-found')}.
|
{error, exmpp_stanza:error(?NS_JABBER_CLIENT, 'item-not-found')}.
|
||||||
@ -3487,7 +3526,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)));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
--- mod_pubsub.erl 2009-11-04 20:42:36.000000000 +0100
|
--- mod_pubsub.erl 2009-11-04 20:44:13.000000000 +0100
|
||||||
+++ mod_pubsub_odbc.erl 2009-11-04 20:43:07.000000000 +0100
|
+++ mod_pubsub_odbc.erl 2009-11-04 20:44:13.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.
|
||||||
@ -322,7 +322,7 @@
|
|||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||||
name = 'query', attrs = QAttrs,
|
name = 'query', attrs = QAttrs,
|
||||||
@@ -1070,7 +875,7 @@
|
@@ -1085,7 +890,7 @@
|
||||||
[] ->
|
[] ->
|
||||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||||
_ ->
|
_ ->
|
||||||
@ -331,7 +331,7 @@
|
|||||||
{result, []} -> ["collection"];
|
{result, []} -> ["collection"];
|
||||||
{result, _} -> ["leaf", "collection"];
|
{result, _} -> ["leaf", "collection"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -1086,8 +891,9 @@
|
@@ -1101,8 +906,9 @@
|
||||||
[];
|
[];
|
||||||
true ->
|
true ->
|
||||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||||
@ -343,9 +343,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)
|
||||||
@@ -1115,14 +921,15 @@
|
@@ -1131,8 +937,9 @@
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_DISCO_ITEMS_s)]},
|
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]},
|
||||||
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_ADHOC_s)]},
|
||||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||||
- lists:map(fun(Feature) ->
|
- lists:map(fun(Feature) ->
|
||||||
- #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
- #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
||||||
@ -353,7 +353,9 @@
|
|||||||
+ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]};
|
+ ("rsm") -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_RSM_s)]};
|
||||||
+ (Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
+ (Feature) -> #xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s++"#"++Feature)]}
|
||||||
end, features(Host, Node))};
|
end, features(Host, Node))};
|
||||||
_ ->
|
?NS_ADHOC_b ->
|
||||||
|
command_disco_info(Host, Node, From);
|
||||||
|
@@ -1142,7 +949,7 @@
|
||||||
node_disco_info(Host, Node, From)
|
node_disco_info(Host, Node, From)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -362,16 +364,29 @@
|
|||||||
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(
|
||||||
@@ -1135,7 +942,7 @@
|
@@ -1155,7 +962,7 @@
|
||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end;
|
end;
|
||||||
|
-iq_disco_items(Host, ?NS_ADHOC_s, _From) ->
|
||||||
|
+iq_disco_items(Host, ?NS_ADHOC_s, _From, _RSM) ->
|
||||||
|
%% TODO: support localization of this string
|
||||||
|
CommandItems = [
|
||||||
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||||
|
@@ -1164,10 +971,10 @@
|
||||||
|
?XMLATTR('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, []};
|
||||||
@@ -1143,10 +950,10 @@
|
@@ -1175,10 +982,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}) ->
|
||||||
@ -385,7 +400,7 @@
|
|||||||
end,
|
end,
|
||||||
Nodes = lists:map(
|
Nodes = lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||||
@@ -1157,9 +964,10 @@
|
@@ -1189,9 +996,10 @@
|
||||||
Items = lists:map(
|
Items = lists:map(
|
||||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||||
@ -398,7 +413,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};
|
||||||
@@ -1290,7 +1098,8 @@
|
@@ -1322,7 +1130,8 @@
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||||
@ -408,7 +423,7 @@
|
|||||||
{get, 'subscriptions'} ->
|
{get, 'subscriptions'} ->
|
||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, 'affiliations'} ->
|
{get, 'affiliations'} ->
|
||||||
@@ -1312,8 +1121,9 @@
|
@@ -1344,8 +1153,9 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||||
@ -420,7 +435,7 @@
|
|||||||
case Action of
|
case Action of
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||||
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
||||||
@@ -1440,7 +1250,8 @@
|
@@ -1479,7 +1289,8 @@
|
||||||
_ -> []
|
_ -> []
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -430,7 +445,7 @@
|
|||||||
sync_dirty) of
|
sync_dirty) of
|
||||||
{result, Res} -> Res;
|
{result, Res} -> Res;
|
||||||
Err -> Err
|
Err -> Err
|
||||||
@@ -1484,7 +1295,7 @@
|
@@ -1523,7 +1334,7 @@
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
@ -439,7 +454,7 @@
|
|||||||
Lang = "en", %% TODO fix
|
Lang = "en", %% TODO fix
|
||||||
{U, S, R} = Subscriber,
|
{U, S, R} = Subscriber,
|
||||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||||
@@ -1514,7 +1325,7 @@
|
@@ -1553,7 +1364,7 @@
|
||||||
lists:foreach(fun(Owner) ->
|
lists:foreach(fun(Owner) ->
|
||||||
{U, S, R} = Owner,
|
{U, S, R} = Owner,
|
||||||
ejabberd_router ! {route, service_jid(Host), exmpp_jid:make(U, S, R), Stanza}
|
ejabberd_router ! {route, service_jid(Host), exmpp_jid:make(U, S, R), Stanza}
|
||||||
@ -448,7 +463,7 @@
|
|||||||
|
|
||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
Els = Packet#xmlel.children,
|
Els = Packet#xmlel.children,
|
||||||
@@ -1556,7 +1367,7 @@
|
@@ -1595,7 +1406,7 @@
|
||||||
end,
|
end,
|
||||||
Stanza = event_stanza(
|
Stanza = event_stanza(
|
||||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||||
@ -457,7 +472,7 @@
|
|||||||
}]),
|
}]),
|
||||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}.
|
ejabberd_router ! {route, service_jid(Host), JID, Stanza}.
|
||||||
|
|
||||||
@@ -1567,14 +1378,14 @@
|
@@ -1606,14 +1417,14 @@
|
||||||
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
||||||
{value, {_, [SAllow]}}} ->
|
{value, {_, [SAllow]}}} ->
|
||||||
Node = string_to_node(SNode),
|
Node = string_to_node(SNode),
|
||||||
@ -475,7 +490,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 ->
|
||||||
@@ -1769,7 +1580,7 @@
|
@@ -1808,7 +1619,7 @@
|
||||||
end,
|
end,
|
||||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||||
@ -484,7 +499,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)),
|
||||||
@@ -1878,7 +1689,7 @@
|
@@ -1917,7 +1728,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) ->
|
||||||
@ -493,7 +508,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -1889,7 +1700,7 @@
|
@@ -1928,7 +1739,7 @@
|
||||||
{undefined, undefined, undefined}
|
{undefined, undefined, undefined}
|
||||||
end,
|
end,
|
||||||
SubId = uniqid(),
|
SubId = uniqid(),
|
||||||
@ -502,7 +517,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),
|
||||||
@@ -1908,9 +1719,13 @@
|
@@ -1947,9 +1758,13 @@
|
||||||
{"", "", ""} ->
|
{"", "", ""} ->
|
||||||
{false, false};
|
{false, false};
|
||||||
_ ->
|
_ ->
|
||||||
@ -519,7 +534,7 @@
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2243,7 +2058,7 @@
|
@@ -2282,7 +2097,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.
|
||||||
@ -528,7 +543,7 @@
|
|||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> get_max_items_node(Host);
|
SMaxItems == "" -> get_max_items_node(Host);
|
||||||
@@ -2282,11 +2097,11 @@
|
@@ -2321,11 +2136,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
@ -542,7 +557,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2299,7 +2114,7 @@
|
@@ -2338,7 +2153,7 @@
|
||||||
%% number of items sent to MaxItems:
|
%% number of items sent to MaxItems:
|
||||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||||
@ -551,7 +566,7 @@
|
|||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2331,17 +2146,29 @@
|
@@ -2370,17 +2185,29 @@
|
||||||
%% @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) ->
|
||||||
@ -588,7 +603,7 @@
|
|||||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = 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, []} ->
|
||||||
@@ -2470,29 +2297,12 @@
|
@@ -2509,29 +2336,12 @@
|
||||||
error ->
|
error ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
_ ->
|
_ ->
|
||||||
@ -621,7 +636,7 @@
|
|||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2547,11 +2357,11 @@
|
@@ -2586,11 +2396,11 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
@ -635,7 +650,7 @@
|
|||||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||||
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||||
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
||||||
@@ -2578,7 +2388,7 @@
|
@@ -2617,7 +2427,7 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
@ -644,7 +659,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -2608,7 +2418,7 @@
|
@@ -2647,7 +2457,7 @@
|
||||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||||
{error, extended_error('bad-request', "invalid-options")};
|
{error, extended_error('bad-request', "invalid-options")};
|
||||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||||
@ -653,7 +668,7 @@
|
|||||||
{error, notfound} ->
|
{error, notfound} ->
|
||||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
@@ -2781,8 +2591,8 @@
|
@@ -2820,8 +2630,8 @@
|
||||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}
|
ejabberd_router ! {route, service_jid(Host), JID, Stanza}
|
||||||
end,
|
end,
|
||||||
@ -664,7 +679,7 @@
|
|||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
|
|
||||||
@@ -3072,7 +2882,7 @@
|
@@ -3111,7 +2921,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,
|
||||||
@ -673,7 +688,7 @@
|
|||||||
{result, CollSubs} -> CollSubs;
|
{result, CollSubs} -> CollSubs;
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
@@ -3086,9 +2896,9 @@
|
@@ -3125,9 +2935,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) ->
|
||||||
@ -685,7 +700,7 @@
|
|||||||
_ -> Acc
|
_ -> Acc
|
||||||
end;
|
end;
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@@ -3096,7 +2906,7 @@
|
@@ -3135,7 +2945,7 @@
|
||||||
end, [], Subs).
|
end, [], Subs).
|
||||||
|
|
||||||
% TODO: merge broadcast code that way
|
% TODO: merge broadcast code that way
|
||||||
@ -694,7 +709,7 @@
|
|||||||
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
||||||
% case (get_option(NodeOptions, Feature) or Force) of
|
% case (get_option(NodeOptions, Feature) or Force) of
|
||||||
% true ->
|
% true ->
|
||||||
@@ -3288,6 +3098,30 @@
|
@@ -3327,6 +3137,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -725,7 +740,7 @@
|
|||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3677,7 +3511,13 @@
|
@@ -3716,7 +3550,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,
|
||||||
@ -740,7 +755,7 @@
|
|||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3697,13 +3537,13 @@
|
@@ -3736,13 +3576,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]),
|
||||||
@ -756,7 +771,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
|
||||||
@@ -3716,8 +3556,15 @@
|
@@ -3755,8 +3595,15 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
@ -774,7 +789,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};
|
||||||
@@ -3725,6 +3572,15 @@
|
@@ -3764,6 +3611,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, 'internal-server-error'};
|
{error, 'internal-server-error'};
|
||||||
@ -790,7 +805,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, 'internal-server-error'};
|
{error, 'internal-server-error'};
|
||||||
@@ -3733,6 +3589,16 @@
|
@@ -3772,6 +3628,16 @@
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user