mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
allow max_items_node use on pep
SVN Revision: 2643
This commit is contained in:
parent
f4e35033e7
commit
65926460b2
@ -202,6 +202,8 @@ init([ServerHost, Opts]) ->
|
||||
ets:insert(gen_mod:get_module_proc(Host, config), {max_items_node, MaxItemsNode}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {nodetree, NodeTree}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {plugins, Plugins}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {last_item_cache, LastItemCache}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {max_items_node, MaxItemsNode}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
|
||||
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
||||
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
||||
|
@ -202,6 +202,8 @@ init([ServerHost, Opts]) ->
|
||||
ets:insert(gen_mod:get_module_proc(Host, config), {max_items_node, MaxItemsNode}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {nodetree, NodeTree}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {plugins, Plugins}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {last_item_cache, LastItemCache}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {max_items_node, MaxItemsNode}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
|
||||
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
||||
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2009-09-25 15:13:13.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2009-09-25 15:13:50.000000000 +0200
|
||||
--- mod_pubsub.erl 2009-10-06 17:21:15.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2009-10-06 17:21:35.000000000 +0200
|
||||
@@ -45,7 +45,7 @@
|
||||
%%% TODO
|
||||
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
||||
@ -40,7 +40,7 @@
|
||||
-define(PLUGIN_PREFIX, "node_").
|
||||
-define(TREE_PREFIX, "nodetree_").
|
||||
|
||||
@@ -225,8 +225,6 @@
|
||||
@@ -227,8 +227,6 @@
|
||||
ok
|
||||
end,
|
||||
ejabberd_router:register_route(Host),
|
||||
@ -49,7 +49,7 @@
|
||||
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
@@ -287,177 +285,7 @@
|
||||
@@ -289,177 +287,7 @@
|
||||
ok
|
||||
end.
|
||||
|
||||
@ -227,7 +227,7 @@
|
||||
|
||||
send_queue(State, Msg) ->
|
||||
Pid = State#state.send_loop,
|
||||
@@ -481,17 +309,15 @@
|
||||
@@ -483,17 +311,15 @@
|
||||
%% for each node From is subscribed to
|
||||
%% and if the node is so configured, send the last published item to From
|
||||
lists:foreach(fun(PType) ->
|
||||
@ -251,7 +251,7 @@
|
||||
true ->
|
||||
% resource not concerned about that subscription
|
||||
ok
|
||||
@@ -819,10 +645,10 @@
|
||||
@@ -821,10 +647,10 @@
|
||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
||||
lists:foreach(fun
|
||||
({Node, subscribed, _, JID}) ->
|
||||
@ -264,7 +264,7 @@
|
||||
true ->
|
||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||
false ->
|
||||
@@ -940,11 +766,12 @@
|
||||
@@ -942,11 +768,12 @@
|
||||
end,
|
||||
ejabberd_router:route(To, From, Res);
|
||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||
@ -279,7 +279,7 @@
|
||||
{result, IQRes} ->
|
||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||
name = 'query', attrs = QAttrs,
|
||||
@@ -1047,7 +874,7 @@
|
||||
@@ -1049,7 +876,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -288,7 +288,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1063,8 +890,9 @@
|
||||
@@ -1065,8 +892,9 @@
|
||||
[];
|
||||
true ->
|
||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||
@ -300,7 +300,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1092,14 +920,15 @@
|
||||
@@ -1094,14 +922,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_PUBSUB_s)]},
|
||||
#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_VCARD_s)]}] ++
|
||||
@ -319,7 +319,7 @@
|
||||
{result, lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
SN = node_to_string(SubNode),
|
||||
@@ -1109,7 +938,7 @@
|
||||
@@ -1111,7 +940,7 @@
|
||||
?XMLATTR('node', SN),
|
||||
?XMLATTR('name', RN)]}
|
||||
end, tree_action(Host, get_subnodes, [Host, [], From]))};
|
||||
@ -328,7 +328,7 @@
|
||||
case string:tokens(Item, "!") of
|
||||
[_SNode, _ItemID] ->
|
||||
{result, []};
|
||||
@@ -1121,10 +950,10 @@
|
||||
@@ -1123,10 +952,10 @@
|
||||
%% TODO That is, remove name attribute (or node?, please check for 2.1)
|
||||
Action =
|
||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
@ -342,7 +342,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
@@ -1140,7 +969,7 @@
|
||||
@@ -1142,7 +971,7 @@
|
||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item', attrs = [?XMLATTR('jid', Host), ?XMLATTR('node', SN),
|
||||
?XMLATTR('name', Name)]}
|
||||
end, NodeItems),
|
||||
@ -351,7 +351,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1274,7 +1103,8 @@
|
||||
@@ -1276,7 +1105,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||
@ -361,7 +361,7 @@
|
||||
{get, 'subscriptions'} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, 'affiliations'} ->
|
||||
@@ -1296,8 +1126,9 @@
|
||||
@@ -1298,8 +1128,9 @@
|
||||
end.
|
||||
|
||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||
@ -373,7 +373,7 @@
|
||||
case Action of
|
||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||
Node = case Host of
|
||||
@@ -1427,7 +1258,8 @@
|
||||
@@ -1429,7 +1260,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -383,7 +383,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1472,7 +1304,7 @@
|
||||
@@ -1474,7 +1306,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -392,7 +392,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
{U, S, R} = Subscriber,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||
@@ -1502,7 +1334,7 @@
|
||||
@@ -1504,7 +1336,7 @@
|
||||
lists:foreach(fun(Owner) ->
|
||||
{U, S, R} = Owner,
|
||||
ejabberd_router ! {route, service_jid(Host), exmpp_jid:make(U, S, R), Stanza}
|
||||
@ -401,7 +401,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
Els = Packet#xmlel.children,
|
||||
@@ -1565,8 +1397,8 @@
|
||||
@@ -1567,8 +1399,8 @@
|
||||
"true" -> true;
|
||||
_ -> false
|
||||
end,
|
||||
@ -412,7 +412,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1756,7 +1588,7 @@
|
||||
@@ -1758,7 +1590,7 @@
|
||||
end,
|
||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||
@ -421,7 +421,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1865,7 +1697,7 @@
|
||||
@@ -1867,7 +1699,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -430,7 +430,7 @@
|
||||
Subscriber = try
|
||||
jlib:short_prepd_jid(exmpp_jid:parse(JID))
|
||||
catch
|
||||
@@ -1873,7 +1705,7 @@
|
||||
@@ -1875,7 +1707,7 @@
|
||||
{undefined, undefined, undefined}
|
||||
end,
|
||||
SubId = uniqid(),
|
||||
@ -439,7 +439,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1892,9 +1724,13 @@
|
||||
@@ -1894,9 +1726,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -456,7 +456,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2219,7 +2055,7 @@
|
||||
@@ -2221,7 +2057,7 @@
|
||||
%% <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
|
||||
%% to read the items.
|
||||
@ -465,7 +465,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2258,11 +2094,11 @@
|
||||
@@ -2260,11 +2096,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -479,7 +479,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2275,7 +2111,7 @@
|
||||
@@ -2277,7 +2113,7 @@
|
||||
%% number of items sent to MaxItems:
|
||||
{result, #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'items', attrs = nodeAttr(Node), children =
|
||||
@ -488,7 +488,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2307,17 +2143,29 @@
|
||||
@@ -2309,17 +2145,29 @@
|
||||
%% @doc <p>Resend the items of a node to the user.</p>
|
||||
%% @todo use cache-last-item feature
|
||||
send_items(Host, Node, NodeId, Type, LJID, last) ->
|
||||
@ -525,7 +525,7 @@
|
||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2446,29 +2294,12 @@
|
||||
@@ -2448,29 +2296,12 @@
|
||||
error ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
@ -558,7 +558,7 @@
|
||||
end, Entities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2523,11 +2354,11 @@
|
||||
@@ -2525,11 +2356,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -572,7 +572,7 @@
|
||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||
attrs = [?XMLATTR('node', node_to_string(Node)),
|
||||
?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||
@@ -2561,7 +2392,7 @@
|
||||
@@ -2563,7 +2394,7 @@
|
||||
_ ->
|
||||
{"", "", ""} %%pablo TODO: "" or <<>> ?. short_jid uses exmpp_jid:node/1, etc. that returns binaries
|
||||
end,
|
||||
@ -581,7 +581,7 @@
|
||||
{result, Subs} = node_call(Type, get_subscriptions,
|
||||
[NodeID, Subscriber]),
|
||||
SubIDs = lists:foldl(fun({subscribed, SID}, Acc) ->
|
||||
@@ -2581,7 +2412,7 @@
|
||||
@@ -2583,7 +2414,7 @@
|
||||
end.
|
||||
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -590,7 +590,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2754,8 +2585,8 @@
|
||||
@@ -2756,8 +2587,8 @@
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
ejabberd_router ! {route, service_jid(Host), JID, Stanza}
|
||||
end,
|
||||
@ -601,7 +601,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3051,7 +2882,7 @@
|
||||
@@ -3053,7 +2884,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -610,7 +610,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3065,9 +2896,9 @@
|
||||
@@ -3067,9 +2898,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -622,7 +622,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3266,6 +3097,30 @@
|
||||
@@ -3268,6 +3099,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -653,7 +653,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3655,7 +3510,13 @@
|
||||
@@ -3657,7 +3512,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -668,7 +668,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3675,13 +3536,13 @@
|
||||
@@ -3677,13 +3538,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -684,7 +684,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3694,8 +3555,15 @@
|
||||
@@ -3696,8 +3557,15 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -702,7 +702,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3703,6 +3571,15 @@
|
||||
@@ -3705,6 +3573,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@ -718,7 +718,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@@ -3711,6 +3588,16 @@
|
||||
@@ -3713,6 +3590,16 @@
|
||||
{error, 'internal-server-error'}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user