mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-28 16:34:13 +01:00
prevent remove_user from blocking gen_server, and allow plugin to change broadcasted payload on publish
SVN Revision: 2666
This commit is contained in:
parent
cbf6abc263
commit
b667148982
@ -42,9 +42,6 @@
|
|||||||
%%% 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.
|
||||||
|
|
||||||
%%% TODO
|
|
||||||
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
|
||||||
|
|
||||||
-module(mod_pubsub).
|
-module(mod_pubsub).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
-version('1.13-0').
|
-version('1.13-0').
|
||||||
@ -780,50 +777,54 @@ handle_cast({presence, User, Server, Resources, JID}, State) ->
|
|||||||
{noreply, send_queue(State, {presence, User, Server, Resources, JID})};
|
{noreply, send_queue(State, {presence, User, Server, Resources, JID})};
|
||||||
|
|
||||||
handle_cast({remove_user, LUser, LServer}, State) ->
|
handle_cast({remove_user, LUser, LServer}, State) ->
|
||||||
Host = State#state.host,
|
spawn(fun() ->
|
||||||
Owner = jlib:make_jid(LUser, LServer, ""),
|
Host = State#state.host,
|
||||||
%% remove user's subscriptions
|
Owner = jlib:make_jid(LUser, LServer, ""),
|
||||||
lists:foreach(fun(PType) ->
|
%% remove user's subscriptions
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Owner]),
|
lists:foreach(fun(PType) ->
|
||||||
lists:foreach(fun
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Owner]),
|
||||||
({#pubsub_node{nodeid = {H, N}}, subscribed, _, JID}) ->
|
lists:foreach(fun
|
||||||
unsubscribe_node(H, N, Owner, JID, all);
|
({#pubsub_node{nodeid = {H, N}}, subscribed, _, JID}) ->
|
||||||
(_) ->
|
unsubscribe_node(H, N, Owner, JID, all);
|
||||||
ok
|
(_) ->
|
||||||
end, Subscriptions),
|
ok
|
||||||
{result, Affiliations} = node_action(Host, PType, get_entity_affiliations, [Host, Owner]),
|
end, Subscriptions),
|
||||||
lists:foreach(fun
|
{result, Affiliations} = node_action(Host, PType, get_entity_affiliations, [Host, Owner]),
|
||||||
({#pubsub_node{nodeid = {H, N}}, owner}) ->
|
lists:foreach(fun
|
||||||
delete_node(H, N, Owner);
|
({#pubsub_node{nodeid = {H, N}}, owner}) ->
|
||||||
(_) ->
|
delete_node(H, N, Owner);
|
||||||
ok
|
(_) ->
|
||||||
end, Affiliations)
|
ok
|
||||||
end, State#state.plugins),
|
end, Affiliations)
|
||||||
|
end, State#state.plugins)
|
||||||
|
end),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_cast({unsubscribe, Subscriber, Owner}, State) ->
|
handle_cast({unsubscribe, Subscriber, Owner}, State) ->
|
||||||
Host = State#state.host,
|
spawn(fun() ->
|
||||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
Host = State#state.host,
|
||||||
lists:foreach(fun(PType) ->
|
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
lists:foreach(fun(PType) ->
|
||||||
lists:foreach(fun
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
||||||
({Node, subscribed, _, JID}) ->
|
lists:foreach(fun
|
||||||
#pubsub_node{options = Options, owners = Owners, type = Type, id = NodeId} = Node,
|
({Node, subscribed, _, JID}) ->
|
||||||
case get_option(Options, access_model) of
|
#pubsub_node{options = Options, owners = Owners, type = Type, id = NodeId} = Node,
|
||||||
presence ->
|
case get_option(Options, access_model) of
|
||||||
case lists:member(BJID, Owners) of
|
presence ->
|
||||||
true ->
|
case lists:member(BJID, Owners) of
|
||||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
true ->
|
||||||
false ->
|
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||||
{result, ok}
|
false ->
|
||||||
end;
|
{result, ok}
|
||||||
_ ->
|
end;
|
||||||
{result, ok}
|
_ ->
|
||||||
end;
|
{result, ok}
|
||||||
(_) ->
|
end;
|
||||||
ok
|
(_) ->
|
||||||
end, Subscriptions)
|
ok
|
||||||
end, State#state.plugins),
|
end, Subscriptions)
|
||||||
|
end, State#state.plugins)
|
||||||
|
end),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
@ -2021,11 +2022,16 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||||||
[{xmlelement, "publish", nodeAttr(Node),
|
[{xmlelement, "publish", nodeAttr(Node),
|
||||||
[{xmlelement, "item", itemAttr(ItemId), []}]}]}],
|
[{xmlelement, "item", itemAttr(ItemId), []}]}]}],
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {TNode, {Result, broadcast, Removed}}} ->
|
{result, {TNode, {Result, Broadcast, Removed}}} ->
|
||||||
NodeId = TNode#pubsub_node.id,
|
NodeId = TNode#pubsub_node.id,
|
||||||
Type = TNode#pubsub_node.type,
|
Type = TNode#pubsub_node.type,
|
||||||
Options = TNode#pubsub_node.options,
|
Options = TNode#pubsub_node.options,
|
||||||
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), Payload),
|
BroadcastPayload = case Broadcast of
|
||||||
|
default -> Payload;
|
||||||
|
broadcast -> Payload;
|
||||||
|
PluginPayload -> PluginPayload
|
||||||
|
end,
|
||||||
|
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), BroadcastPayload),
|
||||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||||
case Result of
|
case Result of
|
||||||
default -> {result, Reply};
|
default -> {result, Reply};
|
||||||
|
@ -42,9 +42,6 @@
|
|||||||
%%% 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.
|
||||||
|
|
||||||
%%% TODO
|
|
||||||
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
|
||||||
|
|
||||||
-module(mod_pubsub_odbc).
|
-module(mod_pubsub_odbc).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
-version('1.13-0').
|
-version('1.13-0').
|
||||||
@ -604,50 +601,54 @@ handle_cast({presence, User, Server, Resources, JID}, State) ->
|
|||||||
{noreply, send_queue(State, {presence, User, Server, Resources, JID})};
|
{noreply, send_queue(State, {presence, User, Server, Resources, JID})};
|
||||||
|
|
||||||
handle_cast({remove_user, LUser, LServer}, State) ->
|
handle_cast({remove_user, LUser, LServer}, State) ->
|
||||||
Host = State#state.host,
|
spawn(fun() ->
|
||||||
Owner = jlib:make_jid(LUser, LServer, ""),
|
Host = State#state.host,
|
||||||
%% remove user's subscriptions
|
Owner = jlib:make_jid(LUser, LServer, ""),
|
||||||
lists:foreach(fun(PType) ->
|
%% remove user's subscriptions
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Owner]),
|
lists:foreach(fun(PType) ->
|
||||||
lists:foreach(fun
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Owner]),
|
||||||
({#pubsub_node{nodeid = {H, N}}, subscribed, _, JID}) ->
|
lists:foreach(fun
|
||||||
unsubscribe_node(H, N, Owner, JID, all);
|
({#pubsub_node{nodeid = {H, N}}, subscribed, _, JID}) ->
|
||||||
(_) ->
|
unsubscribe_node(H, N, Owner, JID, all);
|
||||||
ok
|
(_) ->
|
||||||
end, Subscriptions),
|
ok
|
||||||
{result, Affiliations} = node_action(Host, PType, get_entity_affiliations, [Host, Owner]),
|
end, Subscriptions),
|
||||||
lists:foreach(fun
|
{result, Affiliations} = node_action(Host, PType, get_entity_affiliations, [Host, Owner]),
|
||||||
({#pubsub_node{nodeid = {H, N}}, owner}) ->
|
lists:foreach(fun
|
||||||
delete_node(H, N, Owner);
|
({#pubsub_node{nodeid = {H, N}}, owner}) ->
|
||||||
(_) ->
|
delete_node(H, N, Owner);
|
||||||
ok
|
(_) ->
|
||||||
end, Affiliations)
|
ok
|
||||||
end, State#state.plugins),
|
end, Affiliations)
|
||||||
|
end, State#state.plugins)
|
||||||
|
end),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_cast({unsubscribe, Subscriber, Owner}, State) ->
|
handle_cast({unsubscribe, Subscriber, Owner}, State) ->
|
||||||
Host = State#state.host,
|
spawn(fun() ->
|
||||||
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
Host = State#state.host,
|
||||||
lists:foreach(fun(PType) ->
|
BJID = jlib:jid_tolower(jlib:jid_remove_resource(Owner)),
|
||||||
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
lists:foreach(fun(PType) ->
|
||||||
lists:foreach(fun
|
{result, Subscriptions} = node_action(Host, PType, get_entity_subscriptions, [Host, Subscriber]),
|
||||||
({Node, subscribed, _, JID}) ->
|
lists:foreach(fun
|
||||||
#pubsub_node{options = Options, type = Type, id = NodeId} = Node,
|
({Node, subscribed, _, JID}) ->
|
||||||
case get_option(Options, access_model) of
|
#pubsub_node{options = Options, type = Type, id = NodeId} = Node,
|
||||||
presence ->
|
case get_option(Options, access_model) of
|
||||||
case lists:member(BJID, node_owners(Host, Type, NodeId)) of
|
presence ->
|
||||||
true ->
|
case lists:member(BJID, node_owners(Host, Type, NodeId)) of
|
||||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
true ->
|
||||||
false ->
|
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||||
{result, ok}
|
false ->
|
||||||
end;
|
{result, ok}
|
||||||
_ ->
|
end;
|
||||||
{result, ok}
|
_ ->
|
||||||
end;
|
{result, ok}
|
||||||
(_) ->
|
end;
|
||||||
ok
|
(_) ->
|
||||||
end, Subscriptions)
|
ok
|
||||||
end, State#state.plugins),
|
end, Subscriptions)
|
||||||
|
end, State#state.plugins)
|
||||||
|
end),
|
||||||
{noreply, State};
|
{noreply, State};
|
||||||
|
|
||||||
handle_cast(_Msg, State) ->
|
handle_cast(_Msg, State) ->
|
||||||
@ -1856,11 +1857,16 @@ publish_item(Host, ServerHost, Node, Publisher, ItemId, Payload) ->
|
|||||||
[{xmlelement, "publish", nodeAttr(Node),
|
[{xmlelement, "publish", nodeAttr(Node),
|
||||||
[{xmlelement, "item", itemAttr(ItemId), []}]}]}],
|
[{xmlelement, "item", itemAttr(ItemId), []}]}]}],
|
||||||
case transaction(Host, Node, Action, sync_dirty) of
|
case transaction(Host, Node, Action, sync_dirty) of
|
||||||
{result, {TNode, {Result, broadcast, Removed}}} ->
|
{result, {TNode, {Result, Broadcast, Removed}}} ->
|
||||||
NodeId = TNode#pubsub_node.id,
|
NodeId = TNode#pubsub_node.id,
|
||||||
Type = TNode#pubsub_node.type,
|
Type = TNode#pubsub_node.type,
|
||||||
Options = TNode#pubsub_node.options,
|
Options = TNode#pubsub_node.options,
|
||||||
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), Payload),
|
BroadcastPayload = case Broadcast of
|
||||||
|
default -> Payload;
|
||||||
|
broadcast -> Payload;
|
||||||
|
PluginPayload -> PluginPayload
|
||||||
|
end,
|
||||||
|
broadcast_publish_item(Host, Node, NodeId, Type, Options, Removed, ItemId, jlib:jid_tolower(Publisher), BroadcastPayload),
|
||||||
set_cached_item(Host, NodeId, ItemId, Payload),
|
set_cached_item(Host, NodeId, ItemId, Payload),
|
||||||
case Result of
|
case Result of
|
||||||
default -> {result, Reply};
|
default -> {result, Reply};
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
--- mod_pubsub.erl 2009-10-12 11:57:04.000000000 +0200
|
--- mod_pubsub.erl 2009-10-13 18:30:32.000000000 +0200
|
||||||
+++ mod_pubsub_odbc.erl 2009-10-12 11:57:19.000000000 +0200
|
+++ mod_pubsub_odbc.erl 2009-10-13 18:30:47.000000000 +0200
|
||||||
@@ -45,7 +45,7 @@
|
@@ -42,7 +42,7 @@
|
||||||
%%% TODO
|
%%% 6.2.3.1, 6.2.3.5, and 6.3. For information on subscription leases see
|
||||||
%%% plugin: generate Reply (do not use broadcast atom anymore)
|
%%% XEP-0060 section 12.18.
|
||||||
|
|
||||||
--module(mod_pubsub).
|
--module(mod_pubsub).
|
||||||
+-module(mod_pubsub_odbc).
|
+-module(mod_pubsub_odbc).
|
||||||
-author('christophe.romain@process-one.net').
|
-author('christophe.romain@process-one.net').
|
||||||
-version('1.13-0').
|
-version('1.13-0').
|
||||||
|
|
||||||
@@ -57,9 +57,9 @@
|
@@ -54,9 +54,9 @@
|
||||||
-include("jlib.hrl").
|
-include("jlib.hrl").
|
||||||
-include("pubsub.hrl").
|
-include("pubsub.hrl").
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
%% exports for hooks
|
%% exports for hooks
|
||||||
-export([presence_probe/3,
|
-export([presence_probe/3,
|
||||||
@@ -105,7 +105,7 @@
|
@@ -102,7 +102,7 @@
|
||||||
string_to_affiliation/1,
|
string_to_affiliation/1,
|
||||||
extended_error/2,
|
extended_error/2,
|
||||||
extended_error/3,
|
extended_error/3,
|
||||||
@ -31,7 +31,7 @@
|
|||||||
]).
|
]).
|
||||||
|
|
||||||
%% API and gen_server callbacks
|
%% API and gen_server callbacks
|
||||||
@@ -124,7 +124,7 @@
|
@@ -121,7 +121,7 @@
|
||||||
-export([send_loop/1
|
-export([send_loop/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
@ -40,7 +40,7 @@
|
|||||||
-define(PLUGIN_PREFIX, "node_").
|
-define(PLUGIN_PREFIX, "node_").
|
||||||
-define(TREE_PREFIX, "nodetree_").
|
-define(TREE_PREFIX, "nodetree_").
|
||||||
|
|
||||||
@@ -218,8 +218,6 @@
|
@@ -215,8 +215,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,
|
||||||
@@ -280,178 +278,6 @@
|
@@ -277,178 +275,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
|
||||||
@@ -474,17 +300,15 @@
|
@@ -471,17 +297,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) ->
|
||||||
@ -253,19 +253,19 @@
|
|||||||
% resource not concerned about that subscription
|
% resource not concerned about that subscription
|
||||||
ok
|
ok
|
||||||
@@ -808,10 +632,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}) ->
|
||||||
- #pubsub_node{options = Options, owners = Owners, type = Type, id = NodeId} = Node,
|
- #pubsub_node{options = Options, owners = Owners, type = Type, id = NodeId} = Node,
|
||||||
+ #pubsub_node{options = Options, type = Type, id = NodeId} = Node,
|
+ #pubsub_node{options = Options, type = Type, id = NodeId} = Node,
|
||||||
case get_option(Options, access_model) of
|
case get_option(Options, access_model) of
|
||||||
presence ->
|
presence ->
|
||||||
- case lists:member(BJID, Owners) of
|
- case lists:member(BJID, Owners) of
|
||||||
+ case lists:member(BJID, node_owners(Host, Type, NodeId)) of
|
+ case lists:member(BJID, node_owners(Host, Type, NodeId)) of
|
||||||
true ->
|
true ->
|
||||||
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
node_action(Host, Type, unsubscribe_node, [NodeId, Subscriber, JID, all]);
|
||||||
false ->
|
false ->
|
||||||
@@ -925,7 +749,8 @@
|
@@ -926,7 +750,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,
|
||||||
@@ -1030,7 +855,7 @@
|
@@ -1031,7 +856,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"];
|
||||||
_ -> []
|
_ -> []
|
||||||
@@ -1046,8 +871,9 @@
|
@@ -1047,8 +872,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)
|
||||||
@@ -1075,14 +901,15 @@
|
@@ -1076,14 +902,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),
|
||||||
@@ -1092,7 +919,7 @@
|
@@ -1093,7 +920,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, []};
|
||||||
@@ -1104,10 +931,10 @@
|
@@ -1105,10 +932,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}}) ->
|
||||||
@@ -1123,7 +950,7 @@
|
@@ -1124,7 +951,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};
|
||||||
@@ -1255,7 +1082,8 @@
|
@@ -1256,7 +1083,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"} ->
|
||||||
@@ -1278,7 +1106,9 @@
|
@@ -1279,7 +1107,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
|
||||||
@@ -1404,7 +1234,8 @@
|
@@ -1405,7 +1235,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
|
||||||
@@ -1444,7 +1275,7 @@
|
@@ -1445,7 +1276,7 @@
|
||||||
|
|
||||||
%%% authorization handling
|
%%% authorization handling
|
||||||
|
|
||||||
@ -387,7 +387,7 @@
|
|||||||
Lang = "en", %% TODO fix
|
Lang = "en", %% TODO fix
|
||||||
Stanza = {xmlelement, "message",
|
Stanza = {xmlelement, "message",
|
||||||
[],
|
[],
|
||||||
@@ -1473,7 +1304,7 @@
|
@@ -1474,7 +1305,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,
|
||||||
@@ -1540,8 +1371,8 @@
|
@@ -1541,8 +1372,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 ->
|
||||||
@@ -1727,7 +1558,7 @@
|
@@ -1728,7 +1559,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)),
|
||||||
@@ -1835,7 +1666,7 @@
|
@@ -1836,7 +1667,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) ->
|
||||||
@ -425,7 +425,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -1843,7 +1674,7 @@
|
@@ -1844,7 +1675,7 @@
|
||||||
error -> {"", "", ""};
|
error -> {"", "", ""};
|
||||||
J -> jlib:jid_tolower(J)
|
J -> jlib:jid_tolower(J)
|
||||||
end,
|
end,
|
||||||
@ -434,7 +434,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),
|
||||||
@@ -1862,9 +1693,13 @@
|
@@ -1863,9 +1694,13 @@
|
||||||
{"", "", ""} ->
|
{"", "", ""} ->
|
||||||
{false, false};
|
{false, false};
|
||||||
_ ->
|
_ ->
|
||||||
@ -451,7 +451,7 @@
|
|||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
if
|
if
|
||||||
@@ -2190,7 +2025,7 @@
|
@@ -2196,7 +2031,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.
|
||||||
@ -460,7 +460,7 @@
|
|||||||
MaxItems =
|
MaxItems =
|
||||||
if
|
if
|
||||||
SMaxItems == "" -> get_max_items_node(Host);
|
SMaxItems == "" -> get_max_items_node(Host);
|
||||||
@@ -2229,11 +2064,11 @@
|
@@ -2235,11 +2070,11 @@
|
||||||
node_call(Type, get_items,
|
node_call(Type, get_items,
|
||||||
[NodeId, From,
|
[NodeId, From,
|
||||||
AccessModel, PresenceSubscription, RosterGroup,
|
AccessModel, PresenceSubscription, RosterGroup,
|
||||||
@ -474,7 +474,7 @@
|
|||||||
SendItems = case ItemIDs of
|
SendItems = case ItemIDs of
|
||||||
[] ->
|
[] ->
|
||||||
Items;
|
Items;
|
||||||
@@ -2246,7 +2081,8 @@
|
@@ -2252,7 +2087,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),
|
||||||
@ -484,7 +484,7 @@
|
|||||||
Error ->
|
Error ->
|
||||||
Error
|
Error
|
||||||
end
|
end
|
||||||
@@ -2278,16 +2114,27 @@
|
@@ -2284,16 +2120,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) ->
|
||||||
@ -518,7 +518,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, []} ->
|
||||||
@@ -2413,29 +2260,12 @@
|
@@ -2419,29 +2266,12 @@
|
||||||
error ->
|
error ->
|
||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
_ ->
|
_ ->
|
||||||
@ -551,7 +551,7 @@
|
|||||||
end, Entities),
|
end, Entities),
|
||||||
{result, []};
|
{result, []};
|
||||||
_ ->
|
_ ->
|
||||||
@@ -2488,11 +2318,11 @@
|
@@ -2494,11 +2324,11 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||||
@ -565,7 +565,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}],
|
||||||
@@ -2519,7 +2349,7 @@
|
@@ -2525,7 +2355,7 @@
|
||||||
end.
|
end.
|
||||||
|
|
||||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||||
@ -574,7 +574,7 @@
|
|||||||
{result, GoodSubOpts} -> GoodSubOpts;
|
{result, GoodSubOpts} -> GoodSubOpts;
|
||||||
_ -> invalid
|
_ -> invalid
|
||||||
end,
|
end,
|
||||||
@@ -2548,7 +2378,7 @@
|
@@ -2554,7 +2384,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) ->
|
||||||
@ -583,7 +583,7 @@
|
|||||||
{error, notfound} ->
|
{error, notfound} ->
|
||||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||||
{result, _} ->
|
{result, _} ->
|
||||||
@@ -2716,8 +2546,8 @@
|
@@ -2722,8 +2552,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,
|
||||||
@ -594,7 +594,7 @@
|
|||||||
true ->
|
true ->
|
||||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
|
|
||||||
@@ -3007,7 +2837,7 @@
|
@@ -3013,7 +2843,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,
|
||||||
@ -603,7 +603,7 @@
|
|||||||
{result, CollSubs} -> CollSubs;
|
{result, CollSubs} -> CollSubs;
|
||||||
_ -> []
|
_ -> []
|
||||||
end.
|
end.
|
||||||
@@ -3021,9 +2851,9 @@
|
@@ -3027,9 +2857,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) ->
|
||||||
@ -615,7 +615,7 @@
|
|||||||
_ -> Acc
|
_ -> Acc
|
||||||
end;
|
end;
|
||||||
(_, Acc) ->
|
(_, Acc) ->
|
||||||
@@ -3221,6 +3051,30 @@
|
@@ -3227,6 +3057,30 @@
|
||||||
Result
|
Result
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -646,7 +646,7 @@
|
|||||||
%% @spec (Host, Options) -> MaxItems
|
%% @spec (Host, Options) -> MaxItems
|
||||||
%% Host = host()
|
%% Host = host()
|
||||||
%% Options = [Option]
|
%% Options = [Option]
|
||||||
@@ -3607,7 +3461,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,
|
||||||
@ -661,7 +661,7 @@
|
|||||||
|
|
||||||
%% @doc <p>node plugin call.</p>
|
%% @doc <p>node plugin call.</p>
|
||||||
node_call(Type, Function, Args) ->
|
node_call(Type, Function, Args) ->
|
||||||
@@ -3627,13 +3487,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]),
|
||||||
@ -677,7 +677,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
|
||||||
@@ -3646,8 +3506,14 @@
|
@@ -3652,8 +3512,14 @@
|
||||||
end
|
end
|
||||||
end, Trans).
|
end, Trans).
|
||||||
|
|
||||||
@ -694,7 +694,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};
|
||||||
@@ -3655,6 +3521,15 @@
|
@@ -3661,6 +3527,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};
|
||||||
@ -710,7 +710,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};
|
||||||
@@ -3663,6 +3538,17 @@
|
@@ -3669,6 +3544,17 @@
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user