mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
prevent orphaned pubsub node (EJAB-1233)
This commit is contained in:
parent
2ee788e0bf
commit
217aaf78f9
@ -2444,6 +2444,11 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
||||
Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}=N) ->
|
||||
case lists:member(Owner, Owners) of
|
||||
true ->
|
||||
OwnerJID = exmpp_jid:make(Owner),
|
||||
FilteredEntities = case Owners of
|
||||
[Owner] -> [E || E <- Entities, element(1, E) =/= OwnerJID];
|
||||
_ -> Entities
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
node_call(Type, set_affiliation, [NodeId, JID, Affiliation]),
|
||||
@ -2464,7 +2469,7 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
||||
_ ->
|
||||
ok
|
||||
end
|
||||
end, Entities),
|
||||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
{error, ?ERR_FORBIDDEN}
|
||||
|
@ -2270,10 +2270,15 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
|
||||
Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
case lists:member(Owner, node_owners_call(Type, NodeId)) of
|
||||
true ->
|
||||
OwnerJID = exmpp_jid:make(Owner),
|
||||
FilteredEntities = case Owners of
|
||||
[Owner] -> [E || E <- Entities, element(1, E) =/= OwnerJID];
|
||||
_ -> Entities
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
node_call(Type, set_affiliation, [NodeId, JID, Affiliation])
|
||||
end, Entities),
|
||||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
{error, ?ERR_FORBIDDEN}
|
||||
|
@ -1,5 +1,5 @@
|
||||
--- mod_pubsub.erl 2010-05-12 13:54:26.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-05-12 13:54:33.000000000 +0200
|
||||
--- mod_pubsub.erl 2010-05-19 10:45:13.000000000 +0200
|
||||
+++ mod_pubsub_odbc.erl 2010-05-19 10:46:47.000000000 +0200
|
||||
@@ -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.
|
||||
@ -561,7 +561,7 @@
|
||||
send_items(Host, Node, NodeId, Type, LJID, Number) ->
|
||||
ToSend = case node_action(Host, Type, get_items, [NodeId, LJID]) of
|
||||
{result, []} ->
|
||||
@@ -2441,29 +2267,12 @@
|
||||
@@ -2441,8 +2267,8 @@
|
||||
error ->
|
||||
{error, ?ERR_BAD_REQUEST};
|
||||
_ ->
|
||||
@ -570,6 +570,10 @@
|
||||
+ Action = fun(#pubsub_node{type = Type, id = NodeId}) ->
|
||||
+ case lists:member(Owner, node_owners_call(Type, NodeId)) of
|
||||
true ->
|
||||
OwnerJID = exmpp_jid:make(Owner),
|
||||
FilteredEntities = case Owners of
|
||||
@@ -2451,24 +2277,7 @@
|
||||
end,
|
||||
lists:foreach(
|
||||
fun({JID, Affiliation}) ->
|
||||
- node_call(Type, set_affiliation, [NodeId, JID, Affiliation]),
|
||||
@ -591,10 +595,10 @@
|
||||
- ok
|
||||
- end
|
||||
+ node_call(Type, set_affiliation, [NodeId, JID, Affiliation])
|
||||
end, Entities),
|
||||
end, FilteredEntities),
|
||||
{result, []};
|
||||
_ ->
|
||||
@@ -2516,11 +2325,11 @@
|
||||
@@ -2521,11 +2330,11 @@
|
||||
end.
|
||||
|
||||
read_sub(Subscriber, Node, NodeID, SubID, Lang) ->
|
||||
@ -608,7 +612,7 @@
|
||||
OptionsEl = {xmlelement, "options", [{"jid", jlib:jid_to_string(Subscriber)},
|
||||
{"subid", SubID}|nodeAttr(Node)],
|
||||
[XdataEl]},
|
||||
@@ -2546,7 +2355,7 @@
|
||||
@@ -2551,7 +2360,7 @@
|
||||
end.
|
||||
|
||||
set_options_helper(Configuration, JID, NodeID, SubID, Type) ->
|
||||
@ -617,7 +621,7 @@
|
||||
{result, GoodSubOpts} -> GoodSubOpts;
|
||||
_ -> invalid
|
||||
end,
|
||||
@@ -2575,7 +2384,7 @@
|
||||
@@ -2580,7 +2389,7 @@
|
||||
write_sub(_Subscriber, _NodeID, _SubID, invalid) ->
|
||||
{error, extended_error(?ERR_BAD_REQUEST, "invalid-options")};
|
||||
write_sub(Subscriber, NodeID, SubID, Options) ->
|
||||
@ -626,7 +630,7 @@
|
||||
{error, notfound} ->
|
||||
{error, extended_error(?ERR_NOT_ACCEPTABLE, "invalid-subid")};
|
||||
{result, _} ->
|
||||
@@ -2743,8 +2552,8 @@
|
||||
@@ -2748,8 +2557,8 @@
|
||||
{"subscription", subscription_to_string(Sub)} | nodeAttr(Node)], []}]}]},
|
||||
ejabberd_router:route(service_jid(Host), jlib:make_jid(JID), Stanza)
|
||||
end,
|
||||
@ -637,7 +641,7 @@
|
||||
true ->
|
||||
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||
|
||||
@@ -3074,7 +2883,7 @@
|
||||
@@ -3079,7 +2888,7 @@
|
||||
{Depth, [{N, get_node_subs(N)} || N <- Nodes]}
|
||||
end, tree_call(Host, get_parentnodes_tree, [Host, Node, service_jid(Host)]))}
|
||||
end,
|
||||
@ -646,7 +650,7 @@
|
||||
{result, CollSubs} -> CollSubs;
|
||||
_ -> []
|
||||
end.
|
||||
@@ -3088,9 +2897,9 @@
|
||||
@@ -3093,9 +2902,9 @@
|
||||
|
||||
get_options_for_subs(NodeID, Subs) ->
|
||||
lists:foldl(fun({JID, subscribed, SubID}, Acc) ->
|
||||
@ -658,7 +662,7 @@
|
||||
_ -> Acc
|
||||
end;
|
||||
(_, Acc) ->
|
||||
@@ -3294,6 +3103,30 @@
|
||||
@@ -3299,6 +3108,30 @@
|
||||
Result
|
||||
end.
|
||||
|
||||
@ -689,7 +693,7 @@
|
||||
%% @spec (Host, Options) -> MaxItems
|
||||
%% Host = host()
|
||||
%% Options = [Option]
|
||||
@@ -3689,7 +3522,13 @@
|
||||
@@ -3694,7 +3527,13 @@
|
||||
tree_action(Host, Function, Args) ->
|
||||
?DEBUG("tree_action ~p ~p ~p",[Host,Function,Args]),
|
||||
Fun = fun() -> tree_call(Host, Function, Args) end,
|
||||
@ -704,7 +708,7 @@
|
||||
|
||||
%% @doc <p>node plugin call.</p>
|
||||
node_call(Type, Function, Args) ->
|
||||
@@ -3709,13 +3548,13 @@
|
||||
@@ -3714,13 +3553,13 @@
|
||||
|
||||
node_action(Host, Type, Function, Args) ->
|
||||
?DEBUG("node_action ~p ~p ~p ~p",[Host,Type,Function,Args]),
|
||||
@ -720,7 +724,7 @@
|
||||
case tree_call(Host, get_node, [Host, Node]) of
|
||||
N when is_record(N, pubsub_node) ->
|
||||
case Action(N) of
|
||||
@@ -3728,8 +3567,14 @@
|
||||
@@ -3733,8 +3572,14 @@
|
||||
end
|
||||
end, Trans).
|
||||
|
||||
@ -737,7 +741,7 @@
|
||||
{result, Result} -> {result, Result};
|
||||
{error, Error} -> {error, Error};
|
||||
{atomic, {result, Result}} -> {result, Result};
|
||||
@@ -3737,6 +3582,15 @@
|
||||
@@ -3742,6 +3587,15 @@
|
||||
{aborted, Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{aborted, Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@ -753,7 +757,7 @@
|
||||
{'EXIT', Reason} ->
|
||||
?ERROR_MSG("transaction return internal error: ~p~n", [{'EXIT', Reason}]),
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||
@@ -3745,6 +3599,17 @@
|
||||
@@ -3750,6 +3604,17 @@
|
||||
{error, ?ERR_INTERNAL_SERVER_ERROR}
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user