mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-24 22:25:47 +02:00
add send_loop robustness
SVN Revision: 2899
This commit is contained in:
parent
9f5246cacc
commit
6ad93eb609
|
@ -134,8 +134,7 @@
|
||||||
last_item_cache = false,
|
last_item_cache = false,
|
||||||
max_items_node = ?MAXITEMS,
|
max_items_node = ?MAXITEMS,
|
||||||
nodetree = ?STDTREE,
|
nodetree = ?STDTREE,
|
||||||
plugins = [?STDNODE],
|
plugins = [?STDNODE]}).
|
||||||
send_loop}).
|
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
|
@ -195,6 +194,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), {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), {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), {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}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
||||||
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),
|
||||||
|
@ -229,9 +229,14 @@ init([ServerHost, Opts]) ->
|
||||||
max_items_node = MaxItemsNode,
|
max_items_node = MaxItemsNode,
|
||||||
nodetree = NodeTree,
|
nodetree = NodeTree,
|
||||||
plugins = Plugins},
|
plugins = Plugins},
|
||||||
SendLoop = spawn(?MODULE, send_loop, [State]), %% TODO put this in supervision
|
init_send_loop(ServerHost, State),
|
||||||
register(gen_mod:get_module_proc(ServerHost, ?LOOPNAME), SendLoop),
|
{ok, State}.
|
||||||
{ok, State#state{send_loop = SendLoop}}.
|
|
||||||
|
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
|
%% @spec (Host, ServerHost, Opts) -> Plugins
|
||||||
%% Host = mod_pubsub:host() Opts = [{Key,Value}]
|
%% Host = mod_pubsub:host() Opts = [{Key,Value}]
|
||||||
|
@ -720,8 +725,24 @@ presence_probe(#jid{luser = User, lserver = Server, lresource = Resource}, #jid{
|
||||||
presence(Host, {presence, User, Server, [Resource], JID}).
|
presence(Host, {presence, User, Server, [Resource], JID}).
|
||||||
|
|
||||||
presence(ServerHost, Presence) ->
|
presence(ServerHost, Presence) ->
|
||||||
Proc = gen_mod:get_module_proc(ServerHost, ?LOOPNAME),
|
SendLoop = case whereis(gen_mod:get_module_proc(ServerHost, ?LOOPNAME)) of
|
||||||
Proc ! Presence.
|
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
|
%% subscription hooks handling functions
|
||||||
|
@ -853,8 +874,7 @@ handle_info(_Info, State) ->
|
||||||
terminate(_Reason, #state{host = Host,
|
terminate(_Reason, #state{host = Host,
|
||||||
server_host = ServerHost,
|
server_host = ServerHost,
|
||||||
nodetree = TreePlugin,
|
nodetree = TreePlugin,
|
||||||
plugins = Plugins,
|
plugins = Plugins}) ->
|
||||||
send_loop = SendLoop}) ->
|
|
||||||
ejabberd_router:unregister_route(Host),
|
ejabberd_router:unregister_route(Host),
|
||||||
case lists:member(?PEPNODE, Plugins) of
|
case lists:member(?PEPNODE, Plugins) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -877,7 +897,7 @@ terminate(_Reason, #state{host = Host,
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB),
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB),
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB_OWNER),
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB_OWNER),
|
||||||
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB),
|
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB),
|
||||||
SendLoop ! stop,
|
gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop,
|
||||||
terminate_plugins(Host, ServerHost, Plugins, TreePlugin).
|
terminate_plugins(Host, ServerHost, Plugins, TreePlugin).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -134,8 +134,7 @@
|
||||||
last_item_cache = false,
|
last_item_cache = false,
|
||||||
max_items_node = ?MAXITEMS,
|
max_items_node = ?MAXITEMS,
|
||||||
nodetree = ?STDTREE,
|
nodetree = ?STDTREE,
|
||||||
plugins = [?STDNODE],
|
plugins = [?STDNODE]}).
|
||||||
send_loop}).
|
|
||||||
|
|
||||||
%%====================================================================
|
%%====================================================================
|
||||||
%% API
|
%% API
|
||||||
|
@ -195,6 +194,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), {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), {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), {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}),
|
ets:insert(gen_mod:get_module_proc(ServerHost, config), {host, Host}),
|
||||||
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),
|
||||||
|
@ -227,9 +227,14 @@ init([ServerHost, Opts]) ->
|
||||||
max_items_node = MaxItemsNode,
|
max_items_node = MaxItemsNode,
|
||||||
nodetree = NodeTree,
|
nodetree = NodeTree,
|
||||||
plugins = Plugins},
|
plugins = Plugins},
|
||||||
SendLoop = spawn(?MODULE, send_loop, [State]), %% TODO put this in supervision
|
init_send_loop(ServerHost, State),
|
||||||
register(gen_mod:get_module_proc(ServerHost, ?LOOPNAME), SendLoop),
|
{ok, State}.
|
||||||
{ok, State#state{send_loop = SendLoop}}.
|
|
||||||
|
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
|
%% @spec (Host, ServerHost, Opts) -> Plugins
|
||||||
%% Host = mod_pubsub:host() Opts = [{Key,Value}]
|
%% Host = mod_pubsub:host() Opts = [{Key,Value}]
|
||||||
|
@ -523,8 +528,24 @@ presence_probe(#jid{luser = User, lserver = Server, lresource = Resource}, #jid{
|
||||||
presence(Host, {presence, User, Server, [Resource], JID}).
|
presence(Host, {presence, User, Server, [Resource], JID}).
|
||||||
|
|
||||||
presence(ServerHost, Presence) ->
|
presence(ServerHost, Presence) ->
|
||||||
Proc = gen_mod:get_module_proc(ServerHost, ?LOOPNAME),
|
SendLoop = case whereis(gen_mod:get_module_proc(ServerHost, ?LOOPNAME)) of
|
||||||
Proc ! Presence.
|
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
|
%% subscription hooks handling functions
|
||||||
|
@ -656,8 +677,7 @@ handle_info(_Info, State) ->
|
||||||
terminate(_Reason, #state{host = Host,
|
terminate(_Reason, #state{host = Host,
|
||||||
server_host = ServerHost,
|
server_host = ServerHost,
|
||||||
nodetree = TreePlugin,
|
nodetree = TreePlugin,
|
||||||
plugins = Plugins,
|
plugins = Plugins}) ->
|
||||||
send_loop = SendLoop}) ->
|
|
||||||
ejabberd_router:unregister_route(Host),
|
ejabberd_router:unregister_route(Host),
|
||||||
case lists:member(?PEPNODE, Plugins) of
|
case lists:member(?PEPNODE, Plugins) of
|
||||||
true ->
|
true ->
|
||||||
|
@ -680,7 +700,7 @@ terminate(_Reason, #state{host = Host,
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB),
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB),
|
||||||
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB_OWNER),
|
gen_iq_handler:remove_iq_handler(ejabberd_sm, ServerHost, ?NS_PUBSUB_OWNER),
|
||||||
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB),
|
mod_disco:unregister_feature(ServerHost, ?NS_PUBSUB),
|
||||||
SendLoop ! stop,
|
gen_mod:get_module_proc(ServerHost, ?LOOPNAME) ! stop,
|
||||||
terminate_plugins(Host, ServerHost, Plugins, TreePlugin).
|
terminate_plugins(Host, ServerHost, Plugins, TreePlugin).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
--- mod_pubsub.erl 2010-01-12 16:20:07.000000000 +0100
|
--- mod_pubsub.erl 2010-01-13 10:58:17.000000000 +0100
|
||||||
+++ mod_pubsub_odbc.erl 2010-01-12 16:20:19.000000000 +0100
|
+++ mod_pubsub_odbc.erl 2010-01-13 10:59:59.000000000 +0100
|
||||||
@@ -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,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,
|
||||||
@@ -272,207 +270,14 @@
|
@@ -277,207 +275,14 @@
|
||||||
|
|
||||||
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
init_nodes(Host, ServerHost, _NodeTree, Plugins) ->
|
||||||
%% TODO, this call should be done plugin side
|
%% TODO, this call should be done plugin side
|
||||||
|
@ -260,7 +260,7 @@
|
||||||
send_loop(State) ->
|
send_loop(State) ->
|
||||||
receive
|
receive
|
||||||
{presence, JID, Pid} ->
|
{presence, JID, Pid} ->
|
||||||
@@ -483,17 +288,15 @@
|
@@ -488,17 +293,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) ->
|
||||||
|
@ -284,7 +284,7 @@
|
||||||
true ->
|
true ->
|
||||||
% resource not concerned about that subscription
|
% resource not concerned about that subscription
|
||||||
ok
|
ok
|
||||||
@@ -749,10 +552,10 @@
|
@@ -770,10 +573,10 @@
|
||||||
lists:foreach(fun(PType) ->
|
lists:foreach(fun(PType) ->
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Entity]),
|
||||||
lists:foreach(fun
|
lists:foreach(fun
|
||||||
|
@ -297,7 +297,7 @@
|
||||||
true ->
|
true ->
|
||||||
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
node_action(Host, PType, unsubscribe_node, [NodeId, Entity, JID, all]);
|
||||||
false ->
|
false ->
|
||||||
@@ -919,7 +722,8 @@
|
@@ -939,7 +742,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),
|
||||||
|
@ -307,7 +307,7 @@
|
||||||
{result, IQRes} ->
|
{result, IQRes} ->
|
||||||
jlib:iq_to_xml(
|
jlib:iq_to_xml(
|
||||||
IQ#iq{type = result,
|
IQ#iq{type = result,
|
||||||
@@ -1036,7 +840,7 @@
|
@@ -1056,7 +860,7 @@
|
||||||
[] ->
|
[] ->
|
||||||
["leaf"]; %% No sub-nodes: it's a leaf node
|
["leaf"]; %% No sub-nodes: it's a leaf node
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -316,7 +316,7 @@
|
||||||
{result, []} -> ["collection"];
|
{result, []} -> ["collection"];
|
||||||
{result, _} -> ["leaf", "collection"];
|
{result, _} -> ["leaf", "collection"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -1052,8 +856,9 @@
|
@@ -1072,8 +876,9 @@
|
||||||
[];
|
[];
|
||||||
true ->
|
true ->
|
||||||
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
|
[{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []} |
|
||||||
|
@ -328,7 +328,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)
|
||||||
@@ -1082,8 +887,9 @@
|
@@ -1102,8 +907,9 @@
|
||||||
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
|
{xmlelement, "feature", [{"var", ?NS_PUBSUB}], []},
|
||||||
{xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
|
{xmlelement, "feature", [{"var", ?NS_COMMANDS}], []},
|
||||||
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
|
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}] ++
|
||||||
|
@ -340,7 +340,7 @@
|
||||||
end, features(Host, Node))};
|
end, features(Host, Node))};
|
||||||
<<?NS_COMMANDS>> ->
|
<<?NS_COMMANDS>> ->
|
||||||
command_disco_info(Host, Node, From);
|
command_disco_info(Host, Node, From);
|
||||||
@@ -1093,7 +899,7 @@
|
@@ -1113,7 +919,7 @@
|
||||||
node_disco_info(Host, Node, From)
|
node_disco_info(Host, Node, From)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@
|
||||||
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
case tree_action(Host, get_subnodes, [Host, <<>>, From]) of
|
||||||
Nodes when is_list(Nodes) ->
|
Nodes when is_list(Nodes) ->
|
||||||
{result, lists:map(
|
{result, lists:map(
|
||||||
@@ -1105,14 +911,14 @@
|
@@ -1125,14 +931,14 @@
|
||||||
Other ->
|
Other ->
|
||||||
Other
|
Other
|
||||||
end;
|
end;
|
||||||
|
@ -367,7 +367,7 @@
|
||||||
case string:tokens(Item, "!") of
|
case string:tokens(Item, "!") of
|
||||||
[_SNode, _ItemID] ->
|
[_SNode, _ItemID] ->
|
||||||
{result, []};
|
{result, []};
|
||||||
@@ -1120,10 +926,10 @@
|
@@ -1140,10 +946,10 @@
|
||||||
Node = string_to_node(SNode),
|
Node = string_to_node(SNode),
|
||||||
Action =
|
Action =
|
||||||
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||||
|
@ -381,7 +381,7 @@
|
||||||
end,
|
end,
|
||||||
Nodes = lists:map(
|
Nodes = lists:map(
|
||||||
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
fun(#pubsub_node{nodeid = {_, SubNode}}) ->
|
||||||
@@ -1136,7 +942,7 @@
|
@@ -1156,7 +962,7 @@
|
||||||
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
{result, Name} = node_call(Type, get_item_name, [Host, Node, RN]),
|
||||||
{xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
|
{xmlelement, "item", [{"jid", Host}, {"name", Name}], []}
|
||||||
end, NodeItems),
|
end, NodeItems),
|
||||||
|
@ -390,7 +390,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};
|
||||||
@@ -1265,7 +1071,8 @@
|
@@ -1285,7 +1091,8 @@
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
Acc
|
Acc
|
||||||
end, [], xml:remove_cdata(Els)),
|
end, [], xml:remove_cdata(Els)),
|
||||||
|
@ -400,7 +400,7 @@
|
||||||
{get, "subscriptions"} ->
|
{get, "subscriptions"} ->
|
||||||
get_subscriptions(Host, Node, From, Plugins);
|
get_subscriptions(Host, Node, From, Plugins);
|
||||||
{get, "affiliations"} ->
|
{get, "affiliations"} ->
|
||||||
@@ -1288,7 +1095,9 @@
|
@@ -1308,7 +1115,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,
|
||||||
|
@ -411,7 +411,7 @@
|
||||||
case Action of
|
case Action of
|
||||||
[{xmlelement, Name, Attrs, Els}] ->
|
[{xmlelement, Name, Attrs, Els}] ->
|
||||||
Node = string_to_node(xml:get_attr_s("node", Attrs)),
|
Node = string_to_node(xml:get_attr_s("node", Attrs)),
|
||||||
@@ -1418,7 +1227,8 @@
|
@@ -1438,7 +1247,8 @@
|
||||||
_ -> []
|
_ -> []
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
@ -421,7 +421,7 @@
|
||||||
sync_dirty) of
|
sync_dirty) of
|
||||||
{result, Res} -> Res;
|
{result, Res} -> Res;
|
||||||
Err -> Err
|
Err -> Err
|
||||||
@@ -1457,7 +1267,7 @@
|
@@ -1477,7 +1287,7 @@
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
|
@ -430,7 +430,7 @@
|
||||||
Lang = "en", %% TODO fix
|
Lang = "en", %% TODO fix
|
||||||
Stanza = {xmlelement, "message",
|
Stanza = {xmlelement, "message",
|
||||||
[],
|
[],
|
||||||
@@ -1486,7 +1296,7 @@
|
@@ -1506,7 +1316,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)
|
||||||
|
@ -439,7 +439,7 @@
|
||||||
|
|
||||||
find_authorization_response(Packet) ->
|
find_authorization_response(Packet) ->
|
||||||
{xmlelement, _Name, _Attrs, Els} = Packet,
|
{xmlelement, _Name, _Attrs, Els} = Packet,
|
||||||
@@ -1550,8 +1360,8 @@
|
@@ -1570,8 +1380,8 @@
|
||||||
"true" -> true;
|
"true" -> true;
|
||||||
_ -> false
|
_ -> false
|
||||||
end,
|
end,
|
||||||
|
@ -450,7 +450,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 ->
|
||||||
@@ -1742,7 +1552,7 @@
|
@@ -1762,7 +1572,7 @@
|
||||||
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
Reply = [{xmlelement, "pubsub", [{"xmlns", ?NS_PUBSUB}],
|
||||||
[{xmlelement, "create", nodeAttr(Node),
|
[{xmlelement, "create", nodeAttr(Node),
|
||||||
[]}]}],
|
[]}]}],
|
||||||
|
@ -459,7 +459,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)),
|
||||||
@@ -1850,7 +1660,7 @@
|
@@ -1870,7 +1680,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) ->
|
||||||
|
@ -468,7 +468,7 @@
|
||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -1858,7 +1668,7 @@
|
@@ -1878,7 +1688,7 @@
|
||||||
error -> {"", "", ""};
|
error -> {"", "", ""};
|
||||||
J -> jlib:jid_tolower(J)
|
J -> jlib:jid_tolower(J)
|
||||||
end,
|
end,
|
||||||
|
@ -477,7 +477,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),
|
||||||
@@ -1877,9 +1687,13 @@
|
@@ -1897,9 +1707,13 @@
|
||||||
{"", "", ""} ->
|
{"", "", ""} ->
|
||||||
{false, false};
|
{false, false};
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -494,7 +494,7 @@
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2210,7 +2024,7 @@
|
@@ -2230,7 +2044,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.
|
||||||
|
@ -503,7 +503,7 @@
|
||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> get_max_items_node(Host);
|
SMaxItems == "" -> get_max_items_node(Host);
|
||||||
@@ -2249,11 +2063,11 @@
|
@@ -2269,11 +2083,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
|
@ -517,7 +517,7 @@
|
||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2266,7 +2080,8 @@
|
@@ -2286,7 +2100,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),
|
||||||
|
@ -527,7 +527,7 @@
|
||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2298,16 +2113,27 @@
|
@@ -2318,16 +2133,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) ->
|
||||||
|
@ -561,7 +561,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, []} ->
|
||||||
@@ -2433,29 +2259,12 @@
|
@@ -2453,29 +2279,12 @@
|
||||||
error ->
|
error ->
|
||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
|
@ -594,7 +594,7 @@
|
||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2508,11 +2317,11 @@
|
@@ -2528,11 +2337,11 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
|
@ -608,7 +608,7 @@
|
||||||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||||
{"subid", SubID}|nodeAttr(Node)],
|
{"subid", SubID}|nodeAttr(Node)],
|
||||||
[XdataEl]},
|
[XdataEl]},
|
||||||
@@ -2538,7 +2347,7 @@
|
@@ -2558,7 +2367,7 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
|
@ -617,7 +617,7 @@
|
||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -2567,7 +2376,7 @@
|
@@ -2587,7 +2396,7 @@
|
||||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||||
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
||||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||||
|
@ -626,7 +626,7 @@
|
||||||
{error, notfound} ->
|
{error, notfound} ->
|
||||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
@@ -2735,8 +2544,8 @@
|
@@ -2755,8 +2564,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,
|
||||||
|
@ -637,7 +637,7 @@
|
||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
|
|
||||||
@@ -3020,7 +2829,7 @@
|
@@ -3040,7 +2849,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,
|
||||||
|
@ -646,7 +646,7 @@
|
||||||
{result, CollSubs} -> CollSubs;
|
{result, CollSubs} -> CollSubs;
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
@@ -3034,9 +2843,9 @@
|
@@ -3054,9 +2863,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) ->
|
||||||
|
@ -658,7 +658,7 @@
|
||||||
_ -> Acc
|
_ -> Acc
|
||||||
end;
|
end;
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@@ -3246,6 +3055,30 @@
|
@@ -3266,6 +3075,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -689,7 +689,7 @@
|
||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3638,7 +3471,13 @@
|
@@ -3658,7 +3491,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,
|
||||||
|
@ -704,7 +704,7 @@
|
||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3658,13 +3497,13 @@
|
@@ -3678,13 +3517,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]),
|
||||||
|
@ -720,7 +720,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
|
||||||
@@ -3677,8 +3516,14 @@
|
@@ -3697,8 +3536,14 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
|
@ -737,7 +737,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};
|
||||||
@@ -3686,6 +3531,15 @@
|
@@ -3706,6 +3551,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};
|
||||||
|
@ -753,7 +753,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};
|
||||||
@@ -3694,6 +3548,17 @@
|
@@ -3714,6 +3568,17 @@
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user