mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-26 16:26:24 +01:00
update pubsub patch
SVN Revision: 2691
This commit is contained in:
parent
306cff729c
commit
cd09381efd
@ -1,5 +1,5 @@
|
|||||||
--- mod_pubsub.erl 2009-10-13 18:39:11.000000000 +0200
|
--- mod_pubsub.erl 2009-10-21 10:28:28.000000000 +0200
|
||||||
+++ mod_pubsub_odbc.erl 2009-10-13 18:40:32.000000000 +0200
|
+++ mod_pubsub_odbc.erl 2009-10-21 10:28:28.000000000 +0200
|
||||||
@@ -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.
|
||||||
@ -49,7 +49,18 @@
|
|||||||
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
||||||
State = #state{host = Host,
|
State = #state{host = Host,
|
||||||
server_host = ServerHost,
|
server_host = ServerHost,
|
||||||
@@ -286,177 +284,7 @@
|
@@ -278,206 +276,15 @@
|
||||||
|
|
||||||
|
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
||||||
|
%% TODO, this call should be done plugin side
|
||||||
|
- case lists:member("hometree", Plugins) of
|
||||||
|
+ case lists:member("hometree_odbc", 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"), service_jid(Host), "hometree_odbc"),
|
||||||
|
+ create_node(Host, ServerHost, string_to_node("/home/" ++ ServerHost), service_jid(Host), "hometree_odbc");
|
||||||
|
false ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -179,8 +190,29 @@
|
|||||||
- rename_default_nodeplugin();
|
- rename_default_nodeplugin();
|
||||||
- _ ->
|
- _ ->
|
||||||
- ok
|
- ok
|
||||||
- end.
|
- end,
|
||||||
|
- mnesia:transaction(fun() ->
|
||||||
|
- case catch mnesia:first(pubsub_node) of
|
||||||
|
- {_, L} when is_list(L) ->
|
||||||
|
- lists:foreach(
|
||||||
|
- fun({H, N}) when is_list(N) ->
|
||||||
|
- [Node] = mnesia:read({pubsub_node, {H, N}}),
|
||||||
|
- Type = Node#pubsub_node.type,
|
||||||
|
- BN = element(2, node_call(Type, path_to_node, [N])),
|
||||||
|
- BP = case [element(2, node_call(Type, path_to_node, [P])) || P <- Node#pubsub_node.parents] of
|
||||||
|
- [<<>>] -> [];
|
||||||
|
- Parents -> Parents
|
||||||
|
- end,
|
||||||
|
- mnesia:write(Node#pubsub_node{nodeid={H, BN}, parents=BP}),
|
||||||
|
- mnesia:delete({pubsub_node, {H, N}});
|
||||||
|
- (_) ->
|
||||||
|
- ok
|
||||||
|
- end, mnesia:all_keys(pubsub_node));
|
||||||
|
- _ ->
|
||||||
|
- ok
|
||||||
|
- end
|
||||||
|
- end).
|
||||||
|
-
|
||||||
-rename_default_nodeplugin() ->
|
-rename_default_nodeplugin() ->
|
||||||
- lists:foreach(fun(Node) ->
|
- lists:foreach(fun(Node) ->
|
||||||
- mnesia:dirty_write(Node#pubsub_node{type = "hometree"})
|
- mnesia:dirty_write(Node#pubsub_node{type = "hometree"})
|
||||||
@ -224,10 +256,11 @@
|
|||||||
- _ ->
|
- _ ->
|
||||||
- ok
|
- ok
|
||||||
- end.
|
- end.
|
||||||
|
+
|
||||||
|
|
||||||
send_queue(State, Msg) ->
|
send_queue(State, Msg) ->
|
||||||
Pid = State#state.send_loop,
|
Pid = State#state.send_loop,
|
||||||
@@ -480,17 +308,15 @@
|
@@ -501,17 +308,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) ->
|
||||||
@ -251,7 +284,17 @@
|
|||||||
true ->
|
true ->
|
||||||
% resource not concerned about that subscription
|
% resource not concerned about that subscription
|
||||||
ok
|
ok
|
||||||
@@ -821,10 +647,10 @@
|
@@ -692,8 +497,7 @@
|
||||||
|
end;
|
||||||
|
|
||||||
|
disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
||||||
|
- SNode = binary_to_list(NodeB),
|
||||||
|
- Node = string_to_node(SNode),
|
||||||
|
+ Node = string_to_node(binary_to_list(NodeB)),
|
||||||
|
%% TODO, use iq_disco_items(Host, Node, From)
|
||||||
|
Host = exmpp_jid:prep_domain_as_list(To),
|
||||||
|
LJID = jlib:short_prepd_bare_jid(To),
|
||||||
|
@@ -841,10 +645,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}) ->
|
||||||
@ -264,7 +307,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 ->
|
||||||
@@ -943,11 +769,12 @@
|
@@ -963,11 +767,12 @@
|
||||||
end,
|
end,
|
||||||
ejabberd_router:route(To, From, Res);
|
ejabberd_router:route(To, From, Res);
|
||||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||||
@ -279,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,
|
||||||
@@ -1050,7 +877,7 @@
|
@@ -1070,7 +875,7 @@
|
||||||
[] ->
|
[] ->
|
||||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||||
_ ->
|
_ ->
|
||||||
@ -288,7 +331,7 @@
|
|||||||
{result, []} -> ["collection"];
|
{result, []} -> ["collection"];
|
||||||
{result, _} -> ["leaf", "collection"];
|
{result, _} -> ["leaf", "collection"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -1066,8 +893,9 @@
|
@@ -1086,8 +891,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)]} |
|
||||||
@ -300,7 +343,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)
|
||||||
@@ -1095,14 +923,15 @@
|
@@ -1115,22 +921,23 @@
|
||||||
#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_VCARD_s)]}] ++
|
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||||
@ -317,19 +360,23 @@
|
|||||||
-iq_disco_items(Host, [], From) ->
|
-iq_disco_items(Host, [], From) ->
|
||||||
+iq_disco_items(Host, [], From, _RSM) ->
|
+iq_disco_items(Host, [], From, _RSM) ->
|
||||||
{result, lists:map(
|
{result, lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}, type = Type}) ->
|
||||||
SN = node_to_string(SubNode),
|
- {result, Path} = node_call(Type, node_to_path, [SubNode]),
|
||||||
@@ -1112,7 +941,7 @@
|
- [Name | _] = lists:reverse(Path),
|
||||||
?XMLATTR('node', SN),
|
+ {result, Path} = node_call(Type, node_path, [SubNode]),
|
||||||
?XMLATTR('name', RN)]}
|
+ [Name | _] = lists:reverse(Path),
|
||||||
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host),
|
||||||
|
- ?XMLATTR('name', Name) | nodeAttr(SubNode)]}
|
||||||
|
- end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
||||||
-iq_disco_items(Host, Item, From) ->
|
-iq_disco_items(Host, Item, From) ->
|
||||||
|
+ ?XMLATTR('name', Name) | nodeAttr(SubNode)]}
|
||||||
|
+ end, tree_action(Host, get_subnodes, [Host, <<>>, 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, []};
|
||||||
@@ -1124,10 +953,10 @@
|
@@ -1138,10 +945,10 @@
|
||||||
%% TODO That is, remove name attribute (or node?, please check for 2.1)
|
Node = string_to_node(SNode),
|
||||||
Action =
|
Action =
|
||||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
- % TODO call get_items/6 instead for access control (EJAB-1033)
|
- % TODO call get_items/6 instead for access control (EJAB-1033)
|
||||||
@ -342,16 +389,29 @@
|
|||||||
end,
|
end,
|
||||||
Nodes = lists:map(
|
Nodes = lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||||
@@ -1143,7 +972,7 @@
|
@@ -1150,9 +957,10 @@
|
||||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN),
|
Items = lists:map(
|
||||||
?XMLATTR('name', Name)]}
|
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||||
|
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||||
|
- #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('name', Name)]}
|
||||||
|
+ #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host),
|
||||||
|
+ ?XMLATTR('name', Name)]}
|
||||||
end, NodeItems),
|
end, NodeItems),
|
||||||
- {result, Nodes ++ Items}
|
- {result, Nodes ++ Items}
|
||||||
+ {result, Nodes ++ Items ++ jlib:rsm_encode(RsmOut)}
|
+ {result, Nodes ++ Items ++ jlib:rsm_encode(RsmOut)}
|
||||||
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};
|
||||||
@@ -1277,7 +1106,8 @@
|
@@ -1208,7 +1016,7 @@
|
||||||
|
iq_pubsub(Host, ServerHost, From, IQType, SubEl, Lang, Access, Plugins) ->
|
||||||
|
case exmpp_xml:remove_cdata_from_list(SubEl#xmlel.children) of
|
||||||
|
[#xmlel{name = Name, attrs = Attrs, children = Els} | Rest] ->
|
||||||
|
- Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(attrs, 'node', false)),
|
||||||
|
+ Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', false)),
|
||||||
|
case {IQType, Name} of
|
||||||
|
{set, 'create'} ->
|
||||||
|
Config = case Rest of
|
||||||
|
@@ -1283,7 +1091,8 @@
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||||
@ -361,7 +421,7 @@
|
|||||||
{get, 'subscriptions'} ->
|
{get, 'subscriptions'} ->
|
||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, 'affiliations'} ->
|
{get, 'affiliations'} ->
|
||||||
@@ -1299,8 +1129,9 @@
|
@@ -1305,8 +1114,9 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||||
@ -372,8 +432,8 @@
|
|||||||
+ end, exmpp_xml:get_child_elements(SubEl)),
|
+ end, exmpp_xml:get_child_elements(SubEl)),
|
||||||
case Action of
|
case Action of
|
||||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||||
Node = case Host of
|
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
||||||
@@ -1430,7 +1261,8 @@
|
@@ -1433,7 +1243,8 @@
|
||||||
_ -> []
|
_ -> []
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
@ -383,7 +443,7 @@
|
|||||||
sync_dirty) of
|
sync_dirty) of
|
||||||
{result, Res} -> Res;
|
{result, Res} -> Res;
|
||||||
Err -> Err
|
Err -> Err
|
||||||
@@ -1475,7 +1307,7 @@
|
@@ -1478,7 +1289,7 @@
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
@ -392,7 +452,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 =
|
||||||
@@ -1505,7 +1337,7 @@
|
@@ -1508,7 +1319,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}
|
||||||
@ -401,7 +461,23 @@
|
|||||||
|
|
||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
Els = Packet#xmlel.children,
|
Els = Packet#xmlel.children,
|
||||||
@@ -1568,8 +1400,8 @@
|
@@ -1550,7 +1361,7 @@
|
||||||
|
end,
|
||||||
|
Stanza = event_stanza(
|
||||||
|
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||||
|
- [ ?XMLATTR('jid', exmpp_jid:to_binary(JID)) | nodeAttr(SNode)] ++ SubAttrs
|
||||||
|
+ [?XMLATTR('jid', exmpp_jid:to_binary(JID)) | nodeAttr(SNode)] ++ SubAttrs
|
||||||
|
}]),
|
||||||
|
ejabberd_router ! {route, service_jid(Host), JID, Stanza}.
|
||||||
|
|
||||||
|
@@ -1561,14 +1372,14 @@
|
||||||
|
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
||||||
|
{value, {_, [SAllow]}}} ->
|
||||||
|
Node = string_to_node(SNode),
|
||||||
|
- Subscriber = exmpp_jid:parse(SSubscriber),
|
||||||
|
+ Subscriber = exmpp_jid:parse(SSubscriber),
|
||||||
|
Allow = case SAllow of
|
||||||
|
"1" -> true;
|
||||||
"true" -> true;
|
"true" -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end,
|
end,
|
||||||
@ -412,7 +488,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 ->
|
||||||
@@ -1759,7 +1591,7 @@
|
@@ -1763,7 +1574,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)}]},
|
||||||
@ -421,7 +497,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)),
|
||||||
@@ -1868,7 +1700,7 @@
|
@@ -1872,7 +1683,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) ->
|
||||||
@ -430,7 +506,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -1879,7 +1711,7 @@
|
@@ -1883,7 +1694,7 @@
|
||||||
{undefined, undefined, undefined}
|
{undefined, undefined, undefined}
|
||||||
end,
|
end,
|
||||||
SubId = uniqid(),
|
SubId = uniqid(),
|
||||||
@ -439,7 +515,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),
|
||||||
@@ -1898,9 +1730,13 @@
|
@@ -1902,9 +1713,13 @@
|
||||||
{"", "", ""} ->
|
{"", "", ""} ->
|
||||||
{false, false};
|
{false, false};
|
||||||
_ ->
|
_ ->
|
||||||
@ -456,7 +532,7 @@
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2233,7 +2069,7 @@
|
@@ -2237,7 +2052,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.
|
||||||
@ -465,7 +541,7 @@
|
|||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> get_max_items_node(Host);
|
SMaxItems == "" -> get_max_items_node(Host);
|
||||||
@@ -2272,11 +2108,11 @@
|
@@ -2276,11 +2091,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
@ -479,7 +555,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2289,7 +2125,7 @@
|
@@ -2293,7 +2108,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 =
|
||||||
@ -488,7 +564,7 @@
|
|||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2321,17 +2157,29 @@
|
@@ -2325,17 +2140,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) ->
|
||||||
@ -525,7 +601,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, []} ->
|
||||||
@@ -2460,29 +2308,12 @@
|
@@ -2464,29 +2291,12 @@
|
||||||
error ->
|
error ->
|
||||||
{error, 'bad-request'};
|
{error, 'bad-request'};
|
||||||
_ ->
|
_ ->
|
||||||
@ -558,7 +634,7 @@
|
|||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2537,11 +2368,11 @@
|
@@ -2541,11 +2351,11 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
@ -570,9 +646,9 @@
|
|||||||
- {result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
- {result, XdataEl} = pubsub_subscription:get_options_xform(Lang, Options),
|
||||||
+ {result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options),
|
+ {result, XdataEl} = pubsub_subscription_odbc:get_options_xform(Lang, Options),
|
||||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||||
attrs = [?XMLATTR('node', node_to_string(Node)),
|
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||||
?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
||||||
@@ -2569,7 +2400,7 @@
|
@@ -2572,7 +2382,7 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
@ -581,7 +657,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -2599,7 +2430,7 @@
|
@@ -2602,7 +2412,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) ->
|
||||||
@ -590,7 +666,7 @@
|
|||||||
{error, notfound} ->
|
{error, notfound} ->
|
||||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
@@ -2772,8 +2603,8 @@
|
@@ -2775,8 +2585,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,
|
||||||
@ -601,7 +677,7 @@
|
|||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
|
|
||||||
@@ -3069,7 +2900,7 @@
|
@@ -3066,7 +2876,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,
|
||||||
@ -610,7 +686,7 @@
|
|||||||
{result, CollSubs} -> CollSubs;
|
{result, CollSubs} -> CollSubs;
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
@@ -3083,9 +2914,9 @@
|
@@ -3080,9 +2890,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) ->
|
||||||
@ -622,7 +698,16 @@
|
|||||||
_ -> Acc
|
_ -> Acc
|
||||||
end;
|
end;
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@@ -3284,6 +3115,30 @@
|
@@ -3090,7 +2900,7 @@
|
||||||
|
end, [], Subs).
|
||||||
|
|
||||||
|
% TODO: merge broadcast code that way
|
||||||
|
-% TODO: pablo: Why is this commented? Seems to be present on trunk.
|
||||||
|
+% TODO: pablo: why is this commented?
|
||||||
|
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
||||||
|
% case (get_option(NodeOptions, Feature) or Force) of
|
||||||
|
% true ->
|
||||||
|
@@ -3282,6 +3092,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -653,7 +738,7 @@
|
|||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3673,7 +3528,13 @@
|
@@ -3671,7 +3505,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,
|
||||||
@ -668,7 +753,7 @@
|
|||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3693,13 +3554,13 @@
|
@@ -3691,13 +3531,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]),
|
||||||
@ -684,7 +769,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
|
||||||
@@ -3712,8 +3573,15 @@
|
@@ -3710,8 +3550,15 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
@ -702,7 +787,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};
|
||||||
@@ -3721,6 +3589,15 @@
|
@@ -3719,6 +3566,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'};
|
||||||
@ -718,7 +803,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'};
|
||||||
@@ -3729,6 +3606,16 @@
|
@@ -3727,6 +3583,16 @@
|
||||||
{error, 'internal-server-error'}
|
{error, 'internal-server-error'}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user