mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-26 17:38:45 +01:00
fix manage subscriptions owner's usecase
SVN Revision: 2528
This commit is contained in:
parent
1b81a2e3d6
commit
ca403c25e7
@ -2671,10 +2671,17 @@ set_subscriptions(Host, Node, From, EntitiesEls) ->
|
|||||||
Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
|
Action = fun(#pubsub_node{owners = Owners, type = Type, id = NodeId}) ->
|
||||||
case lists:member(Owner, Owners) of
|
case lists:member(Owner, Owners) of
|
||||||
true ->
|
true ->
|
||||||
lists:foreach(fun({JID, Subscription, SubId}) ->
|
Result = lists:foldl(fun({JID, Subscription, SubId}, Acc) ->
|
||||||
node_call(Type, set_subscriptions, [NodeId, JID, Subscription, SubId])
|
|
||||||
end, Entities),
|
case node_call(Type, set_subscriptions, [NodeId, JID, Subscription, SubId]) of
|
||||||
{result, []};
|
{error, Err} -> [{error, Err} | Acc];
|
||||||
|
_ -> Acc
|
||||||
|
end
|
||||||
|
end, [], Entities),
|
||||||
|
case Result of
|
||||||
|
[] -> {result, []};
|
||||||
|
_ -> {error, ?ERR_NOT_ACCEPTABLE}
|
||||||
|
end;
|
||||||
_ ->
|
_ ->
|
||||||
{error, ?ERR_FORBIDDEN}
|
{error, ?ERR_FORBIDDEN}
|
||||||
end
|
end
|
||||||
|
@ -701,7 +701,10 @@ set_subscriptions(NodeId, Owner, Subscription, SubId) ->
|
|||||||
SubState = get_state(NodeId, SubKey),
|
SubState = get_state(NodeId, SubKey),
|
||||||
case {SubId, SubState#pubsub_state.subscriptions} of
|
case {SubId, SubState#pubsub_state.subscriptions} of
|
||||||
{_, []} ->
|
{_, []} ->
|
||||||
{error, ?ERR_ITEM_NOT_FOUND};
|
case Subscription of
|
||||||
|
none -> ok;
|
||||||
|
_ -> new_subscription(NodeId, Owner, Subscription, SubState)
|
||||||
|
end;
|
||||||
{"", [{_, SID}]} ->
|
{"", [{_, SID}]} ->
|
||||||
case Subscription of
|
case Subscription of
|
||||||
none -> unsub_with_subid(NodeId, SID, SubState);
|
none -> unsub_with_subid(NodeId, SID, SubState);
|
||||||
@ -726,6 +729,12 @@ replace_subscription(_, [], Acc) ->
|
|||||||
replace_subscription({Sub, SubId}, [{_, SubID} | T], Acc) ->
|
replace_subscription({Sub, SubId}, [{_, SubID} | T], Acc) ->
|
||||||
replace_subscription({Sub, SubId}, T, [{Sub, SubID} | Acc]).
|
replace_subscription({Sub, SubId}, T, [{Sub, SubID} | Acc]).
|
||||||
|
|
||||||
|
new_subscription(NodeId, Owner, Subscription, SubState) ->
|
||||||
|
SubId = pubsub_subscription:add_subscription(Owner, NodeId, []),
|
||||||
|
Subscriptions = SubState#pubsub_state.subscriptions,
|
||||||
|
set_state(SubState#pubsub_state{subscriptions = [{Subscription, SubId} | Subscriptions]}),
|
||||||
|
{Subscription, SubId}.
|
||||||
|
|
||||||
unsub_with_subid(NodeId, SubId, SubState) ->
|
unsub_with_subid(NodeId, SubId, SubState) ->
|
||||||
pubsub_subscription:delete_subscription(SubState#pubsub_state.stateid,
|
pubsub_subscription:delete_subscription(SubState#pubsub_state.stateid,
|
||||||
NodeId, SubId),
|
NodeId, SubId),
|
||||||
|
Loading…
Reference in New Issue
Block a user