25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

fix previous fix misplacing (EJAB-840)

SVN Revision: 1803
This commit is contained in:
Christophe Romain 2009-01-11 06:24:42 +00:00
parent 89be1c2ede
commit 56bccce713
2 changed files with 42 additions and 42 deletions

View File

@ -1897,18 +1897,33 @@ set_affiliations(Host, Node, From, EntitiesEls) ->
{error, 'bad-request'}; {error, 'bad-request'};
_ -> _ ->
Action = fun(#pubsub_node{type = Type, owners = Owners}) -> Action = fun(#pubsub_node{type = Type, owners = Owners}) ->
case lists:member(Owner, Owners) of case lists:member(Owner, Owners) of
true -> true ->
lists:foreach( lists:foreach(
fun({JID, Affiliation}) -> fun({JID, Affiliation}) ->
node_call( node_call(Type, set_affiliation, [Host, Node, JID, Affiliation]),
Type, set_affiliation, case Affiliation of
[Host, Node, JID, Affiliation]) owner ->
end, Entities), NewOwner = jlib:short_prepd_bare_jid(JID),
{result, []}; NewOwners = [NewOwner|Owners],
_ -> tree_call(Host, set_node, [N#pubsub_node{owners = NewOwners}]);
{error, 'forbidden'} none ->
end NewOwner = jlib:short_prepd_bare_jid(JID),
case lists:member(OldOwner, Owners) of
true ->
NewOwners = Owners--[OldOwner],
tree_call(Host, set_node, [N#pubsub_node{owners = NewOwners}]);
_ ->
ok
end;
_ ->
ok
end
end, Entities),
{result, []};
_ ->
{error, 'forbidden'}
end
end, end,
transaction(Host, Node, Action, sync_dirty) transaction(Host, Node, Action, sync_dirty)
end. end.
@ -2031,33 +2046,18 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
{error, 'bad-request'}; {error, 'bad-request'};
_ -> _ ->
Action = fun(#pubsub_node{type = Type, owners = Owners}) -> Action = fun(#pubsub_node{type = Type, owners = Owners}) ->
case lists:member(Owner, Owners) of case lists:member(Owner, Owners) of
true -> true ->
lists:foreach( lists:foreach(
fun({JID, Affiliation}) -> fun({JID, Subscription}) ->
node_call(Type, set_affiliation, [Host, Node, JID, Affiliation]), node_call(
case Affiliation of Type, set_subscription,
owner -> [Host, Node, JID, Subscription])
NewOwner = jlib:short_prepd_bare_jid(JID), end, Entities),
NewOwners = [NewOwner|Owners], {result, []};
tree_call(Host, set_node, [N#pubsub_node{owners = NewOwners}]); _ ->
none -> {error, 'forbidden'}
NewOwner = jlib:short_prepd_bare_jid(JID), end
case lists:member(OldOwner, Owners) of
true ->
NewOwners = Owners--[OldOwner],
tree_call(Host, set_node, [N#pubsub_node{owners = NewOwners}]);
_ ->
ok
end;
_ ->
ok
end
end, Entities),
{result, []};
_ ->
{error, 'forbidden'}
end
end, end,
transaction(Host, Node, Action, sync_dirty) transaction(Host, Node, Action, sync_dirty)
end. end.

View File

@ -358,6 +358,9 @@ unsubscribe_node(Host, Node, Sender, Subscriber, _SubId) ->
_ -> get_state(Host, Node, SubKey) _ -> get_state(Host, Node, SubKey)
end, end,
if if
%% Requesting entity is prohibited from unsubscribing entity
not Authorized ->
{error, 'forbidden'};
%% Entity did not specify SubID %% Entity did not specify SubID
%%SubID == "", ?? -> %%SubID == "", ?? ->
%% {error, ?ERR_EXTENDED('bad-request', "subid-required")}; %% {error, ?ERR_EXTENDED('bad-request', "subid-required")};
@ -367,9 +370,6 @@ unsubscribe_node(Host, Node, Sender, Subscriber, _SubId) ->
%% Requesting entity is not a subscriber %% Requesting entity is not a subscriber
SubState#pubsub_state.subscription == none -> SubState#pubsub_state.subscription == none ->
{error, ?ERR_EXTENDED('unexpected-request', "not-subscribed")}; {error, ?ERR_EXTENDED('unexpected-request', "not-subscribed")};
%% Requesting entity is prohibited from unsubscribing entity
not Authorized ->
{error, 'forbidden'};
%% Was just subscriber, remove the record %% Was just subscriber, remove the record
SubState#pubsub_state.affiliation == none -> SubState#pubsub_state.affiliation == none ->
del_state(SubState#pubsub_state.stateid), del_state(SubState#pubsub_state.stateid),