25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-26 16:26:24 +01:00

pubsub now is sync with last trunk

SVN Revision: 2546
This commit is contained in:
Christophe Romain 2009-08-27 08:48:21 +00:00
parent bb08207569
commit f5091aa1ae
3 changed files with 43 additions and 45 deletions

View File

@ -105,7 +105,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
@ -2730,7 +2731,6 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
name = 'subscription', name = 'subscription',
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)), attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)),
?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,
Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) -> Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->

View File

@ -2561,7 +2561,6 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
name = 'subscription', name = 'subscription',
attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)), attrs = [?XMLATTR('jid', exmpp_jid:to_binary(JID)),
?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,
Action = fun(#pubsub_node{type = Type, id = NodeId}) -> Action = fun(#pubsub_node{type = Type, id = NodeId}) ->

View File

@ -1,5 +1,5 @@
--- mod_pubsub.erl 2009-08-25 17:29:57.000000000 -0300 --- mod_pubsub.erl 2009-08-27 10:43:45.000000000 +0200
+++ mod_pubsub_odbc.erl 2009-08-26 12:07:05.000000000 -0300 +++ mod_pubsub_odbc.erl 2009-08-27 10:47:31.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,16 @@
%% exports for hooks %% exports for hooks
-export([presence_probe/3, -export([presence_probe/3,
@@ -105,7 +105,8 @@ @@ -106,7 +106,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, - rename_default_nodeplugin/0
+ escape/1 + escape/1
]). ]).
%% API and gen_server callbacks %% API and gen_server callbacks
@@ -124,7 +125,7 @@ @@ -125,7 +125,7 @@
-export([send_loop/1 -export([send_loop/1
]). ]).
@ -41,7 +40,7 @@
-define(PLUGIN_PREFIX, "node_"). -define(PLUGIN_PREFIX, "node_").
-define(TREE_PREFIX, "nodetree_"). -define(TREE_PREFIX, "nodetree_").
@@ -221,8 +222,6 @@ @@ -222,8 +222,6 @@
ok ok
end, end,
ejabberd_router:register_route(Host), ejabberd_router:register_route(Host),
@ -50,7 +49,7 @@
init_nodes(Host, ServerHost), init_nodes(Host, ServerHost),
State = #state{host = Host, State = #state{host = Host,
server_host = ServerHost, server_host = ServerHost,
@@ -277,177 +276,7 @@ @@ -278,177 +276,7 @@
create_node(Host, ServerHost, ["home", ServerHost], service_jid(Host), "hometree"), create_node(Host, ServerHost, ["home", ServerHost], service_jid(Host), "hometree"),
ok. ok.
@ -228,7 +227,7 @@
send_queue(State, Msg) -> send_queue(State, Msg) ->
Pid = State#state.send_loop, Pid = State#state.send_loop,
@@ -471,17 +300,15 @@ @@ -472,17 +300,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) ->
@ -252,7 +251,7 @@
true -> true ->
% resource not concerned about that subscription % resource not concerned about that subscription
ok ok
@@ -808,10 +635,10 @@ @@ -809,10 +635,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}) ->
@ -265,7 +264,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 ->
@@ -929,11 +756,12 @@ @@ -930,11 +756,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,
@ -280,7 +279,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,
@@ -1036,7 +864,7 @@ @@ -1037,7 +864,7 @@
[] -> [] ->
["leaf"]; %% No sub-nodes: it's a leaf node ["leaf"]; %% No sub-nodes: it's a leaf node
_ -> _ ->
@ -289,7 +288,7 @@
{result, []} -> ["collection"]; {result, []} -> ["collection"];
{result, _} -> ["leaf", "collection"]; {result, _} -> ["leaf", "collection"];
_ -> [] _ -> []
@@ -1052,8 +880,9 @@ @@ -1053,8 +880,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)]} |
@ -301,7 +300,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)
@@ -1081,14 +910,15 @@ @@ -1082,14 +910,15 @@
#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)]}] ++
@ -320,7 +319,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),
@@ -1098,7 +928,7 @@ @@ -1099,7 +928,7 @@
?XMLATTR('node', SN), ?XMLATTR('node', SN),
?XMLATTR('name', RN)]} ?XMLATTR('name', RN)]}
end, tree_action(Host, get_subnodes, [Host, [], From]))}; end, tree_action(Host, get_subnodes, [Host, [], From]))};
@ -329,7 +328,7 @@
case string:tokens(Item, "!") of case string:tokens(Item, "!") of
[_SNode, _ItemID] -> [_SNode, _ItemID] ->
{result, []}; {result, []};
@@ -1110,9 +940,9 @@ @@ -1111,9 +940,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}) ->
@ -341,7 +340,7 @@
end, end,
Nodes = lists:map( Nodes = lists:map(
fun(#pubsub_node{nodeid = {_, SubNode}}) -> fun(#pubsub_node{nodeid = {_, SubNode}}) ->
@@ -1128,7 +958,7 @@ @@ -1129,7 +958,7 @@
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN), #xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN),
?XMLATTR('name', Name)]} ?XMLATTR('name', Name)]}
end, NodeItems), end, NodeItems),
@ -350,7 +349,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};
@@ -1267,7 +1097,8 @@ @@ -1268,7 +1097,8 @@
(_, Acc) -> (_, Acc) ->
Acc Acc
end, [], exmpp_xml:remove_cdata_from_list(Els)), end, [], exmpp_xml:remove_cdata_from_list(Els)),
@ -360,7 +359,7 @@
{get, 'subscriptions'} -> {get, 'subscriptions'} ->
get_subscriptions(Host, Node, From, Plugins); get_subscriptions(Host, Node, From, Plugins);
{get, 'affiliations'} -> {get, 'affiliations'} ->
@@ -1289,8 +1120,11 @@ @@ -1290,8 +1120,11 @@
end. end.
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) -> iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
@ -374,7 +373,7 @@
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 = case Host of
@@ -1420,7 +1254,8 @@ @@ -1421,7 +1254,8 @@
_ -> [] _ -> []
end end
end, end,
@ -384,7 +383,7 @@
sync_dirty) of sync_dirty) of
{result, Res} -> Res; {result, Res} -> Res;
Err -> Err Err -> Err
@@ -1466,7 +1301,7 @@ @@ -1467,7 +1301,7 @@
%%% authorization handling %%% authorization handling
@ -393,7 +392,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 =
@@ -1496,7 +1331,7 @@ @@ -1497,7 +1331,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}
@ -402,7 +401,7 @@
find_authorization_response(Packet) -> find_authorization_response(Packet) ->
Els = Packet#xmlel.children, Els = Packet#xmlel.children,
@@ -1559,8 +1394,8 @@ @@ -1560,8 +1394,8 @@
"true" -> true; "true" -> true;
_ -> false _ -> false
end, end,
@ -413,7 +412,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 ->
@@ -1750,7 +1585,7 @@ @@ -1751,7 +1585,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)}]},
@ -422,7 +421,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)),
@@ -1866,7 +1701,7 @@ @@ -1867,7 +1701,7 @@
{undefined, undefined, undefined} {undefined, undefined, undefined}
end, end,
SubId = uniqid(), SubId = uniqid(),
@ -431,7 +430,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),
@@ -1885,9 +1720,13 @@ @@ -1886,9 +1720,13 @@
{"", "", ""} -> {"", "", ""} ->
{false, false}; {false, false};
_ -> _ ->
@ -448,7 +447,7 @@
end end
end, end,
if if
@@ -2212,7 +2051,7 @@ @@ -2213,7 +2051,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.
@ -457,7 +456,7 @@
MaxItems = MaxItems =
if if
SMaxItems == "" -> ?MAXITEMS; SMaxItems == "" -> ?MAXITEMS;
@@ -2251,11 +2090,11 @@ @@ -2252,11 +2090,11 @@
node_call(Type, get_items, node_call(Type, get_items,
[NodeId, From, [NodeId, From,
AccessModel, PresenceSubscription, RosterGroup, AccessModel, PresenceSubscription, RosterGroup,
@ -471,7 +470,7 @@
SendItems = case ItemIDs of SendItems = case ItemIDs of
[] -> [] ->
Items; Items;
@@ -2268,7 +2107,7 @@ @@ -2269,7 +2107,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 =
@ -480,7 +479,7 @@
Error -> Error ->
Error Error
end end
@@ -2300,16 +2139,25 @@ @@ -2301,16 +2139,25 @@
%% @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) ->
@ -513,7 +512,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, []} ->
@@ -2430,29 +2278,12 @@ @@ -2431,29 +2278,12 @@
error -> error ->
{error, 'bad-request'}; {error, 'bad-request'};
_ -> _ ->
@ -546,8 +545,8 @@
end, Entities), end, Entities),
{result, []}; {result, []};
_ -> _ ->
@@ -2733,8 +2564,8 @@ @@ -2733,8 +2563,8 @@
?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,
- Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) -> - Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
@ -557,7 +556,7 @@
true -> true ->
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) -> Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
@@ -3237,6 +3068,30 @@ @@ -3237,6 +3067,30 @@
Result Result
end. end.
@ -588,7 +587,7 @@
%% @spec (Host, Options) -> MaxItems %% @spec (Host, Options) -> MaxItems
%% Host = host() %% Host = host()
%% Options = [Option] %% Options = [Option]
@@ -3613,7 +3468,13 @@ @@ -3613,7 +3467,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,
@ -603,7 +602,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 +3494,13 @@ @@ -3633,13 +3493,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]),
@ -619,7 +618,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 +3513,15 @@ @@ -3652,8 +3512,15 @@
end end
end, Trans). end, Trans).
@ -637,7 +636,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 +3529,15 @@ @@ -3661,6 +3528,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'};
@ -653,7 +652,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'};
@@ -3669,6 +3546,16 @@ @@ -3669,6 +3545,16 @@
{error, 'internal-server-error'} {error, 'internal-server-error'}
end. end.