mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
Disable use of multi-subscribe and subscription-option on standard plugins
This commit is contained in:
parent
6357ea1d5d
commit
1a32f20c07
@ -51,7 +51,7 @@
|
|||||||
path_to_node/1, can_fetch_item/2, is_subscribed/1]).
|
path_to_node/1, can_fetch_item/2, is_subscribed/1]).
|
||||||
|
|
||||||
init(_Host, _ServerHost, _Opts) ->
|
init(_Host, _ServerHost, _Opts) ->
|
||||||
pubsub_subscription:init(),
|
%%pubsub_subscription:init(),
|
||||||
mnesia:create_table(pubsub_state,
|
mnesia:create_table(pubsub_state,
|
||||||
[{disc_copies, [node()]},
|
[{disc_copies, [node()]},
|
||||||
{type, ordered_set},
|
{type, ordered_set},
|
||||||
@ -97,7 +97,6 @@ features() ->
|
|||||||
<<"instant-nodes">>,
|
<<"instant-nodes">>,
|
||||||
<<"manage-subscriptions">>,
|
<<"manage-subscriptions">>,
|
||||||
<<"modify-affiliations">>,
|
<<"modify-affiliations">>,
|
||||||
<<"multi-subscribe">>,
|
|
||||||
<<"outcast-affiliation">>,
|
<<"outcast-affiliation">>,
|
||||||
<<"persistent-items">>,
|
<<"persistent-items">>,
|
||||||
<<"publish">>,
|
<<"publish">>,
|
||||||
@ -108,8 +107,8 @@ features() ->
|
|||||||
<<"retrieve-items">>,
|
<<"retrieve-items">>,
|
||||||
<<"retrieve-subscriptions">>,
|
<<"retrieve-subscriptions">>,
|
||||||
<<"subscribe">>,
|
<<"subscribe">>,
|
||||||
<<"subscription-notifications">>,
|
<<"subscription-notifications">>].
|
||||||
<<"subscription-options">>].
|
%%<<"subscription-options">>
|
||||||
|
|
||||||
%% @doc Checks if the current user has the permission to create the requested node
|
%% @doc Checks if the current user has the permission to create the requested node
|
||||||
%% <p>In flat node, any unused node name is allowed. The access parameter is also
|
%% <p>In flat node, any unused node name is allowed. The access parameter is also
|
||||||
@ -177,7 +176,7 @@ delete_node(Nodes) ->
|
|||||||
%% </p>
|
%% </p>
|
||||||
%% <p>In the default plugin module, the record is unchanged.</p>
|
%% <p>In the default plugin module, the record is unchanged.</p>
|
||||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
SendLast, PresenceSubscription, RosterGroup, _Options) ->
|
||||||
SubKey = jid:tolower(Subscriber),
|
SubKey = jid:tolower(Subscriber),
|
||||||
GenKey = jid:remove_resource(SubKey),
|
GenKey = jid:remove_resource(SubKey),
|
||||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||||
@ -219,13 +218,20 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
|||||||
%% % Requesting entity is anonymous
|
%% % Requesting entity is anonymous
|
||||||
%% {error, ?ERR_FORBIDDEN};
|
%% {error, ?ERR_FORBIDDEN};
|
||||||
true ->
|
true ->
|
||||||
SubId = pubsub_subscription:add_subscription(Subscriber, Nidx, Options),
|
%%SubId = pubsub_subscription:add_subscription(Subscriber, Nidx, Options),
|
||||||
NewSub = case AccessModel of
|
{NewSub, SubId} = case Subscriptions of
|
||||||
|
[{subscribed, Id}|_] ->
|
||||||
|
{subscribed, Id};
|
||||||
|
[] ->
|
||||||
|
Id = pubsub_subscription:make_subid(),
|
||||||
|
Sub = case AccessModel of
|
||||||
authorize -> pending;
|
authorize -> pending;
|
||||||
_ -> subscribed
|
_ -> subscribed
|
||||||
end,
|
end,
|
||||||
set_state(SubState#pubsub_state{subscriptions =
|
set_state(SubState#pubsub_state{subscriptions =
|
||||||
[{NewSub, SubId} | Subscriptions]}),
|
[{Sub, Id} | Subscriptions]}),
|
||||||
|
{Sub, Id}
|
||||||
|
end,
|
||||||
case {NewSub, SendLast} of
|
case {NewSub, SendLast} of
|
||||||
{subscribed, never} ->
|
{subscribed, never} ->
|
||||||
{result, {default, subscribed, SubId}};
|
{result, {default, subscribed, SubId}};
|
||||||
@ -301,7 +307,7 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
|||||||
|
|
||||||
delete_subscriptions(SubKey, Nidx, Subscriptions, SubState) ->
|
delete_subscriptions(SubKey, Nidx, Subscriptions, SubState) ->
|
||||||
NewSubs = lists:foldl(fun ({Subscription, SubId}, Acc) ->
|
NewSubs = lists:foldl(fun ({Subscription, SubId}, Acc) ->
|
||||||
pubsub_subscription:delete_subscription(SubKey, Nidx, SubId),
|
%%pubsub_subscription:delete_subscription(SubKey, Nidx, SubId),
|
||||||
Acc -- [{Subscription, SubId}]
|
Acc -- [{Subscription, SubId}]
|
||||||
end, SubState#pubsub_state.subscriptions, Subscriptions),
|
end, SubState#pubsub_state.subscriptions, Subscriptions),
|
||||||
case {SubState#pubsub_state.affiliation, NewSubs} of
|
case {SubState#pubsub_state.affiliation, NewSubs} of
|
||||||
@ -601,14 +607,15 @@ replace_subscription(_, [], Acc) -> 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(Nidx, Owner, Sub, SubState) ->
|
new_subscription(_Nidx, _Owner, Sub, SubState) ->
|
||||||
SubId = pubsub_subscription:add_subscription(Owner, Nidx, []),
|
%%SubId = pubsub_subscription:add_subscription(Owner, Nidx, []),
|
||||||
|
SubId = pubsub_subscription:make_subid(),
|
||||||
Subs = SubState#pubsub_state.subscriptions,
|
Subs = SubState#pubsub_state.subscriptions,
|
||||||
set_state(SubState#pubsub_state{subscriptions = [{Sub, SubId} | Subs]}),
|
set_state(SubState#pubsub_state{subscriptions = [{Sub, SubId} | Subs]}),
|
||||||
{Sub, SubId}.
|
{Sub, SubId}.
|
||||||
|
|
||||||
unsub_with_subid(Nidx, SubId, #pubsub_state{stateid = {Entity, _}} = SubState) ->
|
unsub_with_subid(Nidx, SubId, #pubsub_state{stateid = {Entity, _}} = SubState) ->
|
||||||
pubsub_subscription:delete_subscription(SubState#pubsub_state.stateid, Nidx, SubId),
|
%%pubsub_subscription:delete_subscription(SubState#pubsub_state.stateid, Nidx, SubId),
|
||||||
NewSubs = [{S, Sid}
|
NewSubs = [{S, Sid}
|
||||||
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
||||||
SubId =/= Sid],
|
SubId =/= Sid],
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
encode_host/1]).
|
encode_host/1]).
|
||||||
|
|
||||||
init(_Host, _ServerHost, _Opts) ->
|
init(_Host, _ServerHost, _Opts) ->
|
||||||
pubsub_subscription_odbc:init(),
|
%%pubsub_subscription_odbc:init(),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
terminate(_Host, _ServerHost) ->
|
terminate(_Host, _ServerHost) ->
|
||||||
@ -95,7 +95,7 @@ delete_node(Nodes) ->
|
|||||||
{result, {default, broadcast, Reply}}.
|
{result, {default, broadcast, Reply}}.
|
||||||
|
|
||||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
SendLast, PresenceSubscription, RosterGroup, _Options) ->
|
||||||
SubKey = jid:tolower(Subscriber),
|
SubKey = jid:tolower(Subscriber),
|
||||||
GenKey = jid:remove_resource(SubKey),
|
GenKey = jid:remove_resource(SubKey),
|
||||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||||
@ -131,16 +131,26 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
|||||||
%% % Requesting entity is anonymous
|
%% % Requesting entity is anonymous
|
||||||
%% {error, ?ERR_FORBIDDEN};
|
%% {error, ?ERR_FORBIDDEN};
|
||||||
true ->
|
true ->
|
||||||
{result, SubId} = pubsub_subscription_odbc:subscribe_node(Subscriber, Nidx, Options),
|
%%{result, SubId} = pubsub_subscription_odbc:subscribe_node(Subscriber, Nidx, Options),
|
||||||
NewSub = case AccessModel of
|
{NewSub, SubId} = case Subscriptions of
|
||||||
|
[{subscribed, Id}|_] ->
|
||||||
|
{subscribed, Id};
|
||||||
|
[] ->
|
||||||
|
Id = pubsub_subscription_odbc:make_subid(),
|
||||||
|
Sub = case AccessModel of
|
||||||
authorize -> pending;
|
authorize -> pending;
|
||||||
_ -> subscribed
|
_ -> subscribed
|
||||||
end,
|
end,
|
||||||
update_subscription(Nidx, SubKey, [{NewSub, SubId} | Subscriptions]),
|
update_subscription(Nidx, SubKey, [{Sub, Id} | Subscriptions]),
|
||||||
|
{Sub, Id}
|
||||||
|
end,
|
||||||
case {NewSub, SendLast} of
|
case {NewSub, SendLast} of
|
||||||
{subscribed, never} -> {result, {default, subscribed, SubId}};
|
{subscribed, never} ->
|
||||||
{subscribed, _} -> {result, {default, subscribed, SubId, send_last}};
|
{result, {default, subscribed, SubId}};
|
||||||
{_, _} -> {result, {default, pending, SubId}}
|
{subscribed, _} ->
|
||||||
|
{result, {default, subscribed, SubId, send_last}};
|
||||||
|
{_, _} ->
|
||||||
|
{result, {default, pending, SubId}}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
@ -200,7 +210,7 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
|||||||
|
|
||||||
delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscriptions) ->
|
delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscriptions) ->
|
||||||
NewSubs = Subscriptions -- [{Subscription, SubId}],
|
NewSubs = Subscriptions -- [{Subscription, SubId}],
|
||||||
pubsub_subscription_odbc:unsubscribe_node(SubKey, Nidx, SubId),
|
%%pubsub_subscription_odbc:unsubscribe_node(SubKey, Nidx, SubId),
|
||||||
case {Affiliation, NewSubs} of
|
case {Affiliation, NewSubs} of
|
||||||
{none, []} -> del_state(Nidx, SubKey);
|
{none, []} -> del_state(Nidx, SubKey);
|
||||||
_ -> update_subscription(Nidx, SubKey, NewSubs)
|
_ -> update_subscription(Nidx, SubKey, NewSubs)
|
||||||
@ -497,14 +507,15 @@ replace_subscription(_, [], Acc) -> 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(Nidx, Owner, Subscription, SubState) ->
|
new_subscription(_Nidx, _Owner, Subscription, SubState) ->
|
||||||
{result, SubId} = pubsub_subscription_odbc:subscribe_node(Owner, Nidx, []),
|
%%{result, SubId} = pubsub_subscription_odbc:subscribe_node(Owner, Nidx, []),
|
||||||
|
SubId = pubsub_subscription_odbc:make_subid(),
|
||||||
Subscriptions = [{Subscription, SubId} | SubState#pubsub_state.subscriptions],
|
Subscriptions = [{Subscription, SubId} | SubState#pubsub_state.subscriptions],
|
||||||
set_state(SubState#pubsub_state{subscriptions = Subscriptions}),
|
set_state(SubState#pubsub_state{subscriptions = Subscriptions}),
|
||||||
{Subscription, SubId}.
|
{Subscription, SubId}.
|
||||||
|
|
||||||
unsub_with_subid(Nidx, SubId, SubState) ->
|
unsub_with_subid(Nidx, SubId, SubState) ->
|
||||||
pubsub_subscription_odbc:unsubscribe_node(SubState#pubsub_state.stateid, Nidx, SubId),
|
%%pubsub_subscription_odbc:unsubscribe_node(SubState#pubsub_state.stateid, Nidx, SubId),
|
||||||
NewSubs = [{S, Sid}
|
NewSubs = [{S, Sid}
|
||||||
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
||||||
SubId =/= Sid],
|
SubId =/= Sid],
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
%% API
|
%% API
|
||||||
-export([init/0, subscribe_node/3, unsubscribe_node/3,
|
-export([init/0, subscribe_node/3, unsubscribe_node/3,
|
||||||
get_subscription/3, set_subscription/4,
|
get_subscription/3, set_subscription/4,
|
||||||
|
make_subid/0,
|
||||||
get_options_xform/2, parse_options_xform/1]).
|
get_options_xform/2, parse_options_xform/1]).
|
||||||
|
|
||||||
% Internal function also exported for use in transactional bloc from pubsub plugins
|
% Internal function also exported for use in transactional bloc from pubsub plugins
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
%% API
|
%% API
|
||||||
-export([init/0, subscribe_node/3, unsubscribe_node/3,
|
-export([init/0, subscribe_node/3, unsubscribe_node/3,
|
||||||
get_subscription/3, set_subscription/4,
|
get_subscription/3, set_subscription/4,
|
||||||
|
make_subid/0,
|
||||||
get_options_xform/2, parse_options_xform/1]).
|
get_options_xform/2, parse_options_xform/1]).
|
||||||
|
|
||||||
-include("pubsub.hrl").
|
-include("pubsub.hrl").
|
||||||
|
@ -839,15 +839,6 @@ pubsub(Config) ->
|
|||||||
[#pubsub_affiliation{node = Node, type = owner}]}]} =
|
[#pubsub_affiliation{node = Node, type = owner}]}]} =
|
||||||
send_recv(Config, #iq{type = get, to = pubsub_jid(Config),
|
send_recv(Config, #iq{type = get, to = pubsub_jid(Config),
|
||||||
sub_els = [#pubsub{affiliations = []}]}),
|
sub_els = [#pubsub{affiliations = []}]}),
|
||||||
%% Get subscription options
|
|
||||||
true = lists:member(?PUBSUB("subscription-options"), Features),
|
|
||||||
#iq{type = result, sub_els = [#pubsub{options = #pubsub_options{
|
|
||||||
node = Node}}]} =
|
|
||||||
send_recv(Config,
|
|
||||||
#iq{type = get, to = pubsub_jid(Config),
|
|
||||||
sub_els = [#pubsub{options = #pubsub_options{
|
|
||||||
node = Node,
|
|
||||||
jid = my_jid(Config)}}]}),
|
|
||||||
%% Fetching published items from node "presence"
|
%% Fetching published items from node "presence"
|
||||||
#iq{type = result,
|
#iq{type = result,
|
||||||
sub_els = [#pubsub{items = #pubsub_items{
|
sub_els = [#pubsub{items = #pubsub_items{
|
||||||
|
Loading…
Reference in New Issue
Block a user