25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-22 17:28:25 +01:00

allow max_items_node use on pep

SVN Revision: 2642
This commit is contained in:
Christophe Romain 2009-10-06 15:18:58 +00:00
parent c10984f61b
commit 0a77892391
3 changed files with 43 additions and 39 deletions

View File

@ -194,6 +194,8 @@ init([ServerHost, Opts]) ->
ets:insert(gen_mod:get_module_proc(Host, config), {max_items_node, MaxItemsNode}), 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), {nodetree, NodeTree}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {plugins, Plugins}), ets:insert(gen_mod:get_module_proc(ServerHost, config), {plugins, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {last_item_cache, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {max_items_node, LastItemCache}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}), ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
ejabberd_hooks:add(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75), ejabberd_hooks:add(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:add(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75), ejabberd_hooks:add(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75),

View File

@ -194,6 +194,8 @@ init([ServerHost, Opts]) ->
ets:insert(gen_mod:get_module_proc(Host, config), {max_items_node, MaxItemsNode}), 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), {nodetree, NodeTree}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {plugins, Plugins}), ets:insert(gen_mod:get_module_proc(ServerHost, config), {plugins, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {last_item_cache, Plugins}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {max_items_node, LastItemCache}),
ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}), ets:insert(gen_mod:get_module_proc(ServerHost, config), {pep_mapping, PepMapping}),
ejabberd_hooks:add(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75), ejabberd_hooks:add(disco_sm_identity, ServerHost, ?MODULE, disco_sm_identity, 75),
ejabberd_hooks:add(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75), ejabberd_hooks:add(disco_sm_features, ServerHost, ?MODULE, disco_sm_features, 75),

View File

@ -1,5 +1,5 @@
--- mod_pubsub.erl 2009-09-25 15:10:12.000000000 +0200 --- mod_pubsub.erl 2009-10-06 17:17:31.000000000 +0200
+++ mod_pubsub_odbc.erl 2009-09-25 15:11:41.000000000 +0200 +++ mod_pubsub_odbc.erl 2009-10-06 17:18:05.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)
@ -40,7 +40,7 @@
-define(PLUGIN_PREFIX, "node_"). -define(PLUGIN_PREFIX, "node_").
-define(TREE_PREFIX, "nodetree_"). -define(TREE_PREFIX, "nodetree_").
@@ -216,8 +216,6 @@ @@ -218,8 +218,6 @@
ok ok
end, end,
ejabberd_router:register_route(Host), ejabberd_router:register_route(Host),
@ -49,7 +49,7 @@
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,
@@ -278,178 +276,6 @@ @@ -280,178 +278,6 @@
ok ok
end. end.
@ -228,7 +228,7 @@
send_queue(State, Msg) -> send_queue(State, Msg) ->
Pid = State#state.send_loop, Pid = State#state.send_loop,
case is_process_alive(Pid) of case is_process_alive(Pid) of
@@ -472,17 +298,15 @@ @@ -474,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 +252,7 @@
true -> true ->
% resource not concerned about that subscription % resource not concerned about that subscription
ok ok
@@ -806,10 +630,10 @@ @@ -808,10 +632,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 +265,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 ->
@@ -923,7 +747,8 @@ @@ -925,7 +749,8 @@
sub_el = SubEl} = IQ -> sub_el = SubEl} = IQ ->
{xmlelement, _, QAttrs, _} = SubEl, {xmlelement, _, QAttrs, _} = SubEl,
Node = xml:get_attr_s("node", QAttrs), Node = xml:get_attr_s("node", QAttrs),
@ -275,7 +275,7 @@
{result, IQRes} -> {result, IQRes} ->
jlib:iq_to_xml( jlib:iq_to_xml(
IQ#iq{type = result, IQ#iq{type = result,
@@ -1028,7 +853,7 @@ @@ -1030,7 +855,7 @@
[] -> [] ->
["leaf"]; %% No sub-nodes: it's a leaf node ["leaf"]; %% No sub-nodes: it's a leaf node
_ -> _ ->
@ -284,7 +284,7 @@
{result, []} -> ["collection"]; {result, []} -> ["collection"];
{result, _} -> ["leaf", "collection"]; {result, _} -> ["leaf", "collection"];
_ -> [] _ -> []
@@ -1044,8 +869,9 @@ @@ -1046,8 +871,9 @@
[]; [];
true -> true ->
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} | [{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
@ -296,7 +296,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)
@@ -1073,14 +899,15 @@ @@ -1075,14 +901,15 @@
{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_VCARD}], []}] ++ {xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
@ -315,7 +315,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),
@@ -1090,7 +917,7 @@ @@ -1092,7 +919,7 @@
{"node", SN}, {"node", SN},
{"name", RN}], []} {"name", RN}], []}
end, tree_action(Host, get_subnodes, [Host, [], From]))}; end, tree_action(Host, get_subnodes, [Host, [], From]))};
@ -324,7 +324,7 @@
case string:tokens(Item, "!") of case string:tokens(Item, "!") of
[_SNode, _ItemID] -> [_SNode, _ItemID] ->
{result, []}; {result, []};
@@ -1102,10 +929,10 @@ @@ -1104,10 +931,10 @@
%% 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}) ->
@ -338,7 +338,7 @@
end, end,
Nodes = lists:map( Nodes = lists:map(
fun(#pubsub_node{nodeid = {_, SubNode}}) -> fun(#pubsub_node{nodeid = {_, SubNode}}) ->
@@ -1121,7 +948,7 @@ @@ -1123,7 +950,7 @@
{xmlelement, "item", [{"jid", Host}, {"node", SN}, {xmlelement, "item", [{"jid", Host}, {"node", SN},
{"name", Name}], []} {"name", Name}], []}
end, NodeItems), end, NodeItems),
@ -347,7 +347,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};
@@ -1253,7 +1080,8 @@ @@ -1255,7 +1082,8 @@
(_, Acc) -> (_, Acc) ->
Acc Acc
end, [], xml:remove_cdata(Els)), end, [], xml:remove_cdata(Els)),
@ -357,7 +357,7 @@
{get, "subscriptions"} -> {get, "subscriptions"} ->
get_subscriptions(Host, Node, From, Plugins); get_subscriptions(Host, Node, From, Plugins);
{get, "affiliations"} -> {get, "affiliations"} ->
@@ -1276,7 +1104,9 @@ @@ -1278,7 +1106,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,
@ -368,7 +368,7 @@
case Action of case Action of
[{xmlelement, Name, Attrs, Els}] -> [{xmlelement, Name, Attrs, Els}] ->
Node = case Host of Node = case Host of
@@ -1402,7 +1232,8 @@ @@ -1404,7 +1234,8 @@
_ -> [] _ -> []
end end
end, end,
@ -378,7 +378,7 @@
sync_dirty) of sync_dirty) of
{result, Res} -> Res; {result, Res} -> Res;
Err -> Err Err -> Err
@@ -1442,7 +1273,7 @@ @@ -1444,7 +1275,7 @@
%%% authorization handling %%% authorization handling
@ -387,7 +387,7 @@
Lang = "en", %% TODO fix Lang = "en", %% TODO fix
Stanza = {xmlelement, "message", Stanza = {xmlelement, "message",
[], [],
@@ -1471,7 +1302,7 @@ @@ -1473,7 +1304,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}
@ -396,7 +396,7 @@
find_authorization_response(Packet) -> find_authorization_response(Packet) ->
{xmlelement, _Name, _Attrs, Els} = Packet, {xmlelement, _Name, _Attrs, Els} = Packet,
@@ -1538,8 +1369,8 @@ @@ -1540,8 +1371,8 @@
"true" -> true; "true" -> true;
_ -> false _ -> false
end, end,
@ -407,7 +407,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 ->
@@ -1725,7 +1556,7 @@ @@ -1727,7 +1558,7 @@
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}], Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
[{xmlelement, "create", nodeAttr(Node), [{xmlelement, "create", nodeAttr(Node),
[]}]}], []}]}],
@ -416,7 +416,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)),
@@ -1833,12 +1664,12 @@ @@ -1835,12 +1666,12 @@
%%<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) ->
@ -431,7 +431,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),
@@ -1857,9 +1688,13 @@ @@ -1859,9 +1690,13 @@
{"", "", ""} -> {"", "", ""} ->
{false, false}; {false, false};
_ -> _ ->
@ -448,7 +448,7 @@
end end
end, end,
if if
@@ -2182,7 +2017,7 @@ @@ -2184,7 +2019,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 +457,7 @@
MaxItems = MaxItems =
if if
SMaxItems == "" -> get_max_items_node(Host); SMaxItems == "" -> get_max_items_node(Host);
@@ -2221,11 +2056,11 @@ @@ -2223,11 +2058,11 @@
node_call(Type, get_items, node_call(Type, get_items,
[NodeId, From, [NodeId, From,
AccessModel, PresenceSubscription, RosterGroup, AccessModel, PresenceSubscription, RosterGroup,
@ -471,7 +471,7 @@
SendItems = case ItemIDs of SendItems = case ItemIDs of
[] -> [] ->
Items; Items;
@@ -2238,7 +2073,8 @@ @@ -2240,7 +2075,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),
@ -481,7 +481,7 @@
Error -> Error ->
Error Error
end end
@@ -2270,16 +2106,27 @@ @@ -2272,16 +2108,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) ->
@ -515,7 +515,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, []} ->
@@ -2405,29 +2252,12 @@ @@ -2407,29 +2254,12 @@
error -> error ->
{error, ?ERR_BAD_REQUEST}; {error, ?ERR_BAD_REQUEST};
_ -> _ ->
@ -548,7 +548,7 @@
end, Entities), end, Entities),
{result, []}; {result, []};
_ -> _ ->
@@ -2480,11 +2310,11 @@ @@ -2482,11 +2312,11 @@
end. end.
read_sub(Subscriber, Node, NodeID, SubID, Lang) -> read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
@ -562,7 +562,7 @@
OptionsEl = {xmlelement, "options", [{"node", node_to_string(Node)}, OptionsEl = {xmlelement, "options", [{"node", node_to_string(Node)},
{"jid", jlib:jid_to_string(Subscriber)}, {"jid", jlib:jid_to_string(Subscriber)},
{"subid", SubID}], {"subid", SubID}],
@@ -2515,7 +2345,7 @@ @@ -2517,7 +2347,7 @@
error -> {"", "", ""}; error -> {"", "", ""};
J -> jlib:jid_tolower(J) J -> jlib:jid_tolower(J)
end, end,
@ -571,7 +571,7 @@
{result, Subs} = node_call(Type, get_subscriptions, {result, Subs} = node_call(Type, get_subscriptions,
[NodeID, Subscriber]), [NodeID, Subscriber]),
SubIDs = lists:foldl(fun({subscribed, SID}, Acc) -> SubIDs = lists:foldl(fun({subscribed, SID}, Acc) ->
@@ -2535,7 +2365,7 @@ @@ -2537,7 +2367,7 @@
end. end.
write_sub(Subscriber, NodeID, SubID, Options) -> write_sub(Subscriber, NodeID, SubID, Options) ->
@ -580,7 +580,7 @@
{error, notfound} -> {error, notfound} ->
{error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")}; {error, ?ERR_EXTENDED(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
{result, _} -> {result, _} ->
@@ -2703,8 +2533,8 @@ @@ -2705,8 +2535,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,
@ -591,7 +591,7 @@
true -> true ->
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) -> Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
@@ -2994,7 +2824,7 @@ @@ -2996,7 +2826,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,
@ -600,7 +600,7 @@
{result, CollSubs} -> CollSubs; {result, CollSubs} -> CollSubs;
_ -> [] _ -> []
end. end.
@@ -3008,9 +2838,9 @@ @@ -3010,9 +2840,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) ->
@ -612,7 +612,7 @@
_ -> Acc _ -> Acc
end; end;
(_, Acc) -> (_, Acc) ->
@@ -3208,6 +3038,30 @@ @@ -3210,6 +3040,30 @@
Result Result
end. end.
@ -643,7 +643,7 @@
%% @spec (Host, Options) -> MaxItems %% @spec (Host, Options) -> MaxItems
%% Host = host() %% Host = host()
%% Options = [Option] %% Options = [Option]
@@ -3594,7 +3448,13 @@ @@ -3596,7 +3450,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,
@ -658,7 +658,7 @@
%% @doc <p>node plugin call.</p> %% @doc <p>node plugin call.</p>
node_call(Type, Function, Args) -> node_call(Type, Function, Args) ->
@@ -3614,13 +3474,13 @@ @@ -3616,13 +3476,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]),
@ -674,7 +674,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
@@ -3633,8 +3493,14 @@ @@ -3635,8 +3495,14 @@
end end
end, Trans). end, Trans).
@ -691,7 +691,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};
@@ -3642,6 +3508,15 @@ @@ -3644,6 +3510,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};
@ -707,7 +707,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};
@@ -3650,6 +3525,17 @@ @@ -3652,6 +3527,17 @@
{error, ?ERR_INTERNAL_SERVER_ERROR} {error, ?ERR_INTERNAL_SERVER_ERROR}
end. end.