mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
add send_loop robustness
SVN Revision: 2900
This commit is contained in:
parent
e948aafeca
commit
db4fe25274
@ -135,8 +135,7 @@
|
||||
last_item_cache = false,
|
||||
max_items_node = ?MAXITEMS,
|
||||
nodetree = ?STDTREE,
|
||||
plugins = [?STDNODE],
|
||||
send_loop}).
|
||||
plugins = [?STDNODE]}).
|
||||
|
||||
|
||||
%%------------------- Ad hoc commands nodes --------------------------
|
||||
@ -203,6 +202,7 @@ init([ServerHost, Opts]) ->
|
||||
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}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {ignore_pep_from_offline, PepOffline}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
||||
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
||||
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
||||
@ -238,9 +238,14 @@ init([ServerHost, Opts]) ->
|
||||
max_items_node = MaxItemsNode,
|
||||
nodetree = NodeTree,
|
||||
plugins = Plugins},
|
||||
SendLoop = spawn(?MODULE, send_loop, [State]), %% TODO put this in supervision
|
||||
register(gen_mod:get_module_proc(ServerHost, ?LOOPNAME), SendLoop),
|
||||
{ok, State#state{send_loop = SendLoop}}.
|
||||
init_send_loop(ServerHost, State),
|
||||
{ok, State}.
|
||||
|
||||
init_send_loop(ServerHost, State) ->
|
||||
Proc = gen_mod:get_module_proc(ServerHost, ?LOOPNAME),
|
||||
SendLoop = spawn(?MODULE, send_loop, [State]),
|
||||
register(Proc, SendLoop),
|
||||
SendLoop.
|
||||
|
||||
%% @spec (Host, ServerHost, Opts) -> Plugins
|
||||
%% Host = mod_pubsub:host() Opts = [{Key,Value}]
|
||||
@ -737,8 +742,24 @@ presence_probe(Peer, JID, Pid) ->
|
||||
end
|
||||
end.
|
||||
presence(ServerHost, Presence) ->
|
||||
Proc = gen_mod:get_module_proc(ServerHost, ?LOOPNAME),
|
||||
Proc ! Presence.
|
||||
SendLoop = case whereis(gen_mod:get_module_proc(ServerHost, ?LOOPNAME)) of
|
||||
undefined ->
|
||||
% in case send_loop process died, we rebuild a minimal State record and respawn it
|
||||
Host = host(ServerHost),
|
||||
Plugins = plugins(Host),
|
||||
PepOffline = case catch ets:lookup(gen_mod:get_module_proc(ServerHost, config), ignore_pep_from_offline) of
|
||||
[{ignore_pep_from_offline, PO}] -> PO;
|
||||
_ -> true
|
||||
end,
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
ignore_pep_from_offline = PepOffline,
|
||||
plugins = Plugins},
|
||||
init_send_loop(ServerHost, State);
|
||||
Pid ->
|
||||
Pid
|
||||
end,
|
||||
SendLoop ! Presence.
|
||||
|
||||
%% -------
|
||||
%% subscription hooks handling functions
|
||||
@ -871,8 +892,7 @@ handle_info(_Info, State) ->
|
||||
terminate(_Reason, #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
nodetree = TreePlugin,
|
||||
plugins = Plugins,
|
||||
send_loop = SendLoop}) ->
|
||||
plugins = Plugins}) ->
|
||||
ejabberd_router:unregister_route(Host),
|
||||
ServerHostB = list_to_binary(ServerHost),
|
||||
case lists:member(?PEPNODE, Plugins) of
|
||||
@ -899,7 +919,7 @@ terminate(_Reason, #state{host = Host,
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHostB, ?NS_PUBSUB),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHostB, ?NS_PUBSUB_OWNER),
|
||||
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB_s),
|
||||
SendLoop ! stop,
|
||||
gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop,
|
||||
terminate_plugins(Host, ServerHost, Plugins, TreePlugin).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
|
@ -135,8 +135,7 @@
|
||||
last_item_cache = false,
|
||||
max_items_node = ?MAXITEMS,
|
||||
nodetree = ?STDTREE,
|
||||
plugins = [?STDNODE],
|
||||
send_loop}).
|
||||
plugins = [?STDNODE]}).
|
||||
|
||||
|
||||
%%------------------- Ad hoc commands nodes --------------------------
|
||||
@ -203,6 +202,7 @@ init([ServerHost, Opts]) ->
|
||||
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}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {ignore_pep_from_offline, PepOffline}),
|
||||
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
||||
ejabberd_hooks:add(disco_sm_identity, ServerHostB, ?MODULE, disco_sm_identity, 75),
|
||||
ejabberd_hooks:add(disco_sm_features, ServerHostB, ?MODULE, disco_sm_features, 75),
|
||||
@ -236,9 +236,14 @@ init([ServerHost, Opts]) ->
|
||||
max_items_node = MaxItemsNode,
|
||||
nodetree = NodeTree,
|
||||
plugins = Plugins},
|
||||
SendLoop = spawn(?MODULE, send_loop, [State]), %% TODO put this in supervision
|
||||
register(gen_mod:get_module_proc(ServerHost, ?LOOPNAME), SendLoop),
|
||||
{ok, State#state{send_loop = SendLoop}}.
|
||||
init_send_loop(ServerHost, State),
|
||||
{ok, State}.
|
||||
|
||||
init_send_loop(ServerHost, State) ->
|
||||
Proc = gen_mod:get_module_proc(ServerHost, ?LOOPNAME),
|
||||
SendLoop = spawn(?MODULE, send_loop, [State]),
|
||||
register(Proc, SendLoop),
|
||||
SendLoop.
|
||||
|
||||
%% @spec (Host, ServerHost, Opts) -> Plugins
|
||||
%% Host = mod_pubsub:host() Opts = [{Key,Value}]
|
||||
@ -542,8 +547,24 @@ presence_probe(Peer, JID, Pid) ->
|
||||
end
|
||||
end.
|
||||
presence(ServerHost, Presence) ->
|
||||
Proc = gen_mod:get_module_proc(ServerHost, ?LOOPNAME),
|
||||
Proc ! Presence.
|
||||
SendLoop = case whereis(gen_mod:get_module_proc(ServerHost, ?LOOPNAME)) of
|
||||
undefined ->
|
||||
% in case send_loop process died, we rebuild a minimal State record and respawn it
|
||||
Host = host(ServerHost),
|
||||
Plugins = plugins(Host),
|
||||
PepOffline = case catch ets:lookup(gen_mod:get_module_proc(ServerHost, config), ignore_pep_from_offline) of
|
||||
[{ignore_pep_from_offline, PO}] -> PO;
|
||||
_ -> true
|
||||
end,
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
ignore_pep_from_offline = PepOffline,
|
||||
plugins = Plugins},
|
||||
init_send_loop(ServerHost, State);
|
||||
Pid ->
|
||||
Pid
|
||||
end,
|
||||
SendLoop ! Presence.
|
||||
|
||||
%% -------
|
||||
%% subscription hooks handling functions
|
||||
@ -676,8 +697,7 @@ handle_info(_Info, State) ->
|
||||
terminate(_Reason, #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
nodetree = TreePlugin,
|
||||
plugins = Plugins,
|
||||
send_loop = SendLoop}) ->
|
||||
plugins = Plugins}) ->
|
||||
ejabberd_router:unregister_route(Host),
|
||||
ServerHostB = list_to_binary(ServerHost),
|
||||
case lists:member(?PEPNODE, Plugins) of
|
||||
@ -704,7 +724,7 @@ terminate(_Reason, #state{host = Host,
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHostB, ?NS_PUBSUB),
|
||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHostB, ?NS_PUBSUB_OWNER),
|
||||
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB_s),
|
||||
SendLoop ! stop,
|
||||
gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop,
|
||||
terminate_plugins(Host, ServerHost, Plugins, TreePlugin).
|
||||
|
||||
%%--------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2010-01-12 16:08:14.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2010-01-12 16:10:52.000000000 +0100
|
||||
--- mod_pubsub.erl 2010-01-13 11:01:09.000000000 +0100
|
||||
+++ mod_pubsub_odbc.erl 2010-01-13 11:01:49.000000000 +0100
|
||||
@@ -42,7 +42,7 @@
|
||||
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
||||
%%% XEP-0060 section 12.18.
|
||||
@ -49,7 +49,7 @@
|
||||
init_nodes(Host, ServerHost, NodeTree, Plugins),
|
||||
State = #state{host = Host,
|
||||
server_host = ServerHost,
|
||||
@@ -281,206 +279,15 @@
|
||||
@@ -286,206 +284,15 @@
|
||||
|
||||
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
||||
%% TODO, this call should be done plugin side
|
||||
@ -260,7 +260,7 @@
|
||||
|
||||
send_loop(State) ->
|
||||
receive
|
||||
@@ -492,17 +299,15 @@
|
||||
@@ -497,17 +304,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) ->
|
||||
@ -284,7 +284,7 @@
|
||||
true ->
|
||||
% resource not concerned about that subscription
|
||||
ok
|
||||
@@ -683,8 +488,7 @@
|
||||
@@ -688,8 +493,7 @@
|
||||
end;
|
||||
|
||||
disco_sm_items(Acc, From, To, NodeB, _Lang) ->
|
||||
@ -294,7 +294,7 @@
|
||||
%% TODO, use iq_disco_items(Host, Node, From)
|
||||
Host = exmpp_jid:prep_domain_as_list(To),
|
||||
LJID = jlib:short_prepd_bare_jid(To),
|
||||
@@ -718,6 +522,7 @@
|
||||
@@ -723,6 +527,7 @@
|
||||
%% -------
|
||||
%% presence hooks handling functions
|
||||
%%
|
||||
@ -302,7 +302,7 @@
|
||||
presence_probe(Peer, JID, Pid) ->
|
||||
case exmpp_jid:full_compare(Peer, JID) of
|
||||
true -> %% JID are equals
|
||||
@@ -766,10 +571,10 @@
|
||||
@@ -787,10 +592,10 @@
|
||||
lists:foreach(fun(PType) ->
|
||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
||||
lists:foreach(fun
|
||||
@ -315,7 +315,7 @@
|
||||
true ->
|
||||
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
||||
false ->
|
||||
@@ -941,11 +746,12 @@
|
||||
@@ -961,11 +766,12 @@
|
||||
end,
|
||||
ejabberd_router:route(To, From, Res);
|
||||
#iq{type = get, ns = ?NS_DISCO_ITEMS,
|
||||
@ -330,7 +330,7 @@
|
||||
{result, IQRes} ->
|
||||
Result = #xmlel{ns = ?NS_DISCO_ITEMS,
|
||||
name = 'query', attrs = QAttrs,
|
||||
@@ -1063,7 +869,7 @@
|
||||
@@ -1083,7 +889,7 @@
|
||||
[] ->
|
||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||
_ ->
|
||||
@ -339,7 +339,7 @@
|
||||
{result, []} -> ["collection"];
|
||||
{result, _} -> ["leaf", "collection"];
|
||||
_ -> []
|
||||
@@ -1079,8 +885,9 @@
|
||||
@@ -1099,8 +905,9 @@
|
||||
[];
|
||||
true ->
|
||||
[#xmlel{ns = ?NS_DISCO_INFO, name = 'feature', attrs = [?XMLATTR('var', ?NS_PUBSUB_s)]} |
|
||||
@ -351,7 +351,7 @@
|
||||
end, features(Type))]
|
||||
end,
|
||||
%% TODO: add meta-data info (spec section 5.4)
|
||||
@@ -1109,8 +916,9 @@
|
||||
@@ -1129,8 +936,9 @@
|
||||
#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)]}] ++
|
||||
@ -363,7 +363,7 @@
|
||||
end, features(Host, Node))};
|
||||
?NS_ADHOC_b ->
|
||||
command_disco_info(Host, Node, From);
|
||||
@@ -1120,7 +928,7 @@
|
||||
@@ -1140,7 +948,7 @@
|
||||
node_disco_info(Host, Node, From)
|
||||
end.
|
||||
|
||||
@ -372,7 +372,7 @@
|
||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||
Nodes when is_list(Nodes) ->
|
||||
{result, lists:map(
|
||||
@@ -1133,7 +941,7 @@
|
||||
@@ -1153,7 +961,7 @@
|
||||
Other ->
|
||||
Other
|
||||
end;
|
||||
@ -381,7 +381,7 @@
|
||||
%% TODO: support localization of this string
|
||||
CommandItems = [
|
||||
#xmlel{ns = ?NS_DISCO_ITEMS, name = 'item',
|
||||
@@ -1142,10 +950,10 @@
|
||||
@@ -1162,10 +970,10 @@
|
||||
?XMLATTR('name', "Get Pending")
|
||||
]}],
|
||||
{result, CommandItems};
|
||||
@ -394,7 +394,7 @@
|
||||
case string:tokens(Item, "!") of
|
||||
[_SNode, _ItemID] ->
|
||||
{result, []};
|
||||
@@ -1153,10 +961,10 @@
|
||||
@@ -1173,10 +981,10 @@
|
||||
Node = string_to_node(SNode),
|
||||
Action =
|
||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
@ -408,7 +408,7 @@
|
||||
end,
|
||||
Nodes = lists:map(
|
||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||
@@ -1167,9 +975,10 @@
|
||||
@@ -1187,9 +995,10 @@
|
||||
Items = lists:map(
|
||||
fun(#pubsub_item{itemid = {RN, _}}) ->
|
||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||
@ -421,7 +421,7 @@
|
||||
end,
|
||||
case transaction(Host, Node, Action, sync_dirty) of
|
||||
{result, {_, Result}} -> {result, Result};
|
||||
@@ -1300,7 +1109,8 @@
|
||||
@@ -1320,7 +1129,8 @@
|
||||
(_, Acc) ->
|
||||
Acc
|
||||
end, [], exmpp_xml:remove_cdata_from_list(Els)),
|
||||
@ -431,7 +431,7 @@
|
||||
{get, 'subscriptions'} ->
|
||||
get_subscriptions(Host, Node, From, Plugins);
|
||||
{get, 'affiliations'} ->
|
||||
@@ -1322,8 +1132,9 @@
|
||||
@@ -1342,8 +1152,9 @@
|
||||
end.
|
||||
|
||||
iq_pubsub_owner(Host, ServerHost, From, IQType, SubEl, Lang) ->
|
||||
@ -443,7 +443,7 @@
|
||||
case Action of
|
||||
[#xmlel{name = Name, attrs = Attrs, children = Els}] ->
|
||||
Node = string_to_node(exmpp_xml:get_attribute_from_list_as_list(Attrs, 'node', "")),
|
||||
@@ -1457,7 +1268,8 @@
|
||||
@@ -1477,7 +1288,8 @@
|
||||
_ -> []
|
||||
end
|
||||
end,
|
||||
@ -453,7 +453,7 @@
|
||||
sync_dirty) of
|
||||
{result, Res} -> Res;
|
||||
Err -> Err
|
||||
@@ -1501,7 +1313,7 @@
|
||||
@@ -1521,7 +1333,7 @@
|
||||
|
||||
%%% authorization handling
|
||||
|
||||
@ -462,7 +462,7 @@
|
||||
Lang = "en", %% TODO fix
|
||||
{U, S, R} = Subscriber,
|
||||
Stanza = #xmlel{ns = ?NS_JABBER_CLIENT, name = 'message', children =
|
||||
@@ -1531,7 +1343,7 @@
|
||||
@@ -1551,7 +1363,7 @@
|
||||
lists:foreach(fun(Owner) ->
|
||||
{U, S, R} = Owner,
|
||||
ejabberd_router:route(service_jid(Host), exmpp_jid:make(U, S, R), Stanza)
|
||||
@ -471,7 +471,7 @@
|
||||
|
||||
find_authorization_response(Packet) ->
|
||||
Els = Packet#xmlel.children,
|
||||
@@ -1573,7 +1385,7 @@
|
||||
@@ -1593,7 +1405,7 @@
|
||||
end,
|
||||
Stanza = event_stanza(
|
||||
[#xmlel{ns = ?NS_PUBSUB_EVENT, name = 'subscription', attrs =
|
||||
@ -480,7 +480,7 @@
|
||||
}]),
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza).
|
||||
|
||||
@@ -1584,14 +1396,14 @@
|
||||
@@ -1604,14 +1416,14 @@
|
||||
{{value, {_, [SNode]}}, {value, {_, [SSubscriber]}},
|
||||
{value, {_, [SAllow]}}} ->
|
||||
Node = string_to_node(SNode),
|
||||
@ -498,7 +498,7 @@
|
||||
{result, Subscriptions} = node_call(Type, get_subscriptions, [NodeId, Subscriber]),
|
||||
if
|
||||
not IsApprover ->
|
||||
@@ -1786,7 +1598,7 @@
|
||||
@@ -1806,7 +1618,7 @@
|
||||
end,
|
||||
Reply = #xmlel{ns = ?NS_PUBSUB, name = 'pubsub', children =
|
||||
[#xmlel{ns = ?NS_PUBSUB, name = 'create', attrs = nodeAttr(Node)}]},
|
||||
@ -507,7 +507,7 @@
|
||||
{result, {Result, broadcast}} ->
|
||||
%%Lang = "en", %% TODO: fix
|
||||
%%OwnerKey = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||
@@ -1895,7 +1707,7 @@
|
||||
@@ -1915,7 +1727,7 @@
|
||||
%%<li>The node does not exist.</li>
|
||||
%%</ul>
|
||||
subscribe_node(Host, Node, From, JID, Configuration) ->
|
||||
@ -516,7 +516,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -1906,7 +1718,7 @@
|
||||
@@ -1926,7 +1738,7 @@
|
||||
{undefined, undefined, undefined}
|
||||
end,
|
||||
SubId = uniqid(),
|
||||
@ -525,7 +525,7 @@
|
||||
Features = features(Type),
|
||||
SubscribeFeature = lists:member("subscribe", Features),
|
||||
OptionsFeature = lists:member("subscription-options", Features),
|
||||
@@ -1925,9 +1737,13 @@
|
||||
@@ -1945,9 +1757,13 @@
|
||||
{"", "", ""} ->
|
||||
{false, false};
|
||||
_ ->
|
||||
@ -542,7 +542,7 @@
|
||||
end
|
||||
end,
|
||||
if
|
||||
@@ -2260,7 +2076,7 @@
|
||||
@@ -2280,7 +2096,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.
|
||||
@ -551,7 +551,7 @@
|
||||
MaxItems =
|
||||
if
|
||||
SMaxItems == "" -> get_max_items_node(Host);
|
||||
@@ -2299,11 +2115,11 @@
|
||||
@@ -2319,11 +2135,11 @@
|
||||
node_call(Type, get_items,
|
||||
[NodeId, From,
|
||||
AccessModel, PresenceSubscription, RosterGroup,
|
||||
@ -565,7 +565,7 @@
|
||||
SendItems = case ItemIDs of
|
||||
[] ->
|
||||
Items;
|
||||
@@ -2316,7 +2132,7 @@
|
||||
@@ -2336,7 +2152,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 =
|
||||
@ -574,7 +574,7 @@
|
||||
Error ->
|
||||
Error
|
||||
end
|
||||
@@ -2348,17 +2164,29 @@
|
||||
@@ -2368,17 +2184,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) ->
|
||||
@ -611,7 +611,7 @@
|
||||
send_items(Host, Node, NodeId, Type, {LU, LS, LR} = LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2487,29 +2315,12 @@
|
||||
@@ -2507,29 +2335,12 @@
|
||||
error ->
|
||||
{error, 'bad-request'};
|
||||
_ ->
|
||||
@ -644,7 +644,7 @@
|
||||
end, Entities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2564,11 +2375,11 @@
|
||||
@@ -2584,11 +2395,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -658,7 +658,7 @@
|
||||
OptionsEl = #xmlel{ns = ?NS_PUBSUB, name = 'options',
|
||||
attrs = [ ?XMLATTR('jid', exmpp_jid:to_binary(Subscriber)),
|
||||
?XMLATTR('Subid', SubID) | nodeAttr(Node)],
|
||||
@@ -2595,7 +2406,7 @@
|
||||
@@ -2615,7 +2426,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -667,7 +667,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2625,7 +2436,7 @@
|
||||
@@ -2645,7 +2456,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error('bad-request', "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -676,7 +676,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error('not-acceptable', "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2798,8 +2609,8 @@
|
||||
@@ -2818,8 +2629,8 @@
|
||||
?XMLATTR('subsription', subscription_to_string(Sub)) | nodeAttr(Node)]}]}]},
|
||||
ejabberd_router:route(service_jid(Host), JID, Stanza)
|
||||
end,
|
||||
@ -687,7 +687,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3088,7 +2899,7 @@
|
||||
@@ -3108,7 +2919,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -696,7 +696,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3102,9 +2913,9 @@
|
||||
@@ -3122,9 +2933,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -708,7 +708,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3112,7 +2923,7 @@
|
||||
@@ -3132,7 +2943,7 @@
|
||||
end, [], Subs).
|
||||
|
||||
% TODO: merge broadcast code that way
|
||||
@ -717,7 +717,7 @@
|
||||
%broadcast(Host, Node, NodeId, Type, NodeOptions, Feature, Force, ElName, SubEls) ->
|
||||
% case (get_option(NodeOptions, Feature) or Force) of
|
||||
% true ->
|
||||
@@ -3333,6 +3144,30 @@
|
||||
@@ -3353,6 +3164,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -748,7 +748,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3728,7 +3563,13 @@
|
||||
@@ -3748,7 +3583,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -763,7 +763,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3748,13 +3589,13 @@
|
||||
@@ -3768,13 +3609,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -779,7 +779,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3767,8 +3608,15 @@
|
||||
@@ -3787,8 +3628,15 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -797,7 +797,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3776,6 +3624,15 @@
|
||||
@@ -3796,6 +3644,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@ -813,7 +813,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, 'internal-server-error'};
|
||||
@@ -3784,6 +3641,16 @@
|
||||
@@ -3804,6 +3661,16 @@
|
||||
{error, 'internal-server-error'}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user