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]).
|
||||
|
||||
init(_Host, _ServerHost, _Opts) ->
|
||||
pubsub_subscription:init(),
|
||||
%%pubsub_subscription:init(),
|
||||
mnesia:create_table(pubsub_state,
|
||||
[{disc_copies, [node()]},
|
||||
{type, ordered_set},
|
||||
@ -97,7 +97,6 @@ features() ->
|
||||
<<"instant-nodes">>,
|
||||
<<"manage-subscriptions">>,
|
||||
<<"modify-affiliations">>,
|
||||
<<"multi-subscribe">>,
|
||||
<<"outcast-affiliation">>,
|
||||
<<"persistent-items">>,
|
||||
<<"publish">>,
|
||||
@ -108,8 +107,8 @@ features() ->
|
||||
<<"retrieve-items">>,
|
||||
<<"retrieve-subscriptions">>,
|
||||
<<"subscribe">>,
|
||||
<<"subscription-notifications">>,
|
||||
<<"subscription-options">>].
|
||||
<<"subscription-notifications">>].
|
||||
%%<<"subscription-options">>
|
||||
|
||||
%% @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
|
||||
@ -177,7 +176,7 @@ delete_node(Nodes) ->
|
||||
%% </p>
|
||||
%% <p>In the default plugin module, the record is unchanged.</p>
|
||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||
SendLast, PresenceSubscription, RosterGroup, _Options) ->
|
||||
SubKey = jid:tolower(Subscriber),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||
@ -219,13 +218,20 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
%% % Requesting entity is anonymous
|
||||
%% {error, ?ERR_FORBIDDEN};
|
||||
true ->
|
||||
SubId = pubsub_subscription:add_subscription(Subscriber, Nidx, Options),
|
||||
NewSub = case AccessModel of
|
||||
authorize -> pending;
|
||||
_ -> subscribed
|
||||
%%SubId = pubsub_subscription:add_subscription(Subscriber, Nidx, Options),
|
||||
{NewSub, SubId} = case Subscriptions of
|
||||
[{subscribed, Id}|_] ->
|
||||
{subscribed, Id};
|
||||
[] ->
|
||||
Id = pubsub_subscription:make_subid(),
|
||||
Sub = case AccessModel of
|
||||
authorize -> pending;
|
||||
_ -> subscribed
|
||||
end,
|
||||
set_state(SubState#pubsub_state{subscriptions =
|
||||
[{Sub, Id} | Subscriptions]}),
|
||||
{Sub, Id}
|
||||
end,
|
||||
set_state(SubState#pubsub_state{subscriptions =
|
||||
[{NewSub, SubId} | Subscriptions]}),
|
||||
case {NewSub, SendLast} of
|
||||
{subscribed, never} ->
|
||||
{result, {default, subscribed, SubId}};
|
||||
@ -301,7 +307,7 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||
|
||||
delete_subscriptions(SubKey, Nidx, Subscriptions, SubState) ->
|
||||
NewSubs = lists:foldl(fun ({Subscription, SubId}, Acc) ->
|
||||
pubsub_subscription:delete_subscription(SubKey, Nidx, SubId),
|
||||
%%pubsub_subscription:delete_subscription(SubKey, Nidx, SubId),
|
||||
Acc -- [{Subscription, SubId}]
|
||||
end, SubState#pubsub_state.subscriptions, Subscriptions),
|
||||
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}, T, [{Sub, SubId} | Acc]).
|
||||
|
||||
new_subscription(Nidx, Owner, Sub, SubState) ->
|
||||
SubId = pubsub_subscription:add_subscription(Owner, Nidx, []),
|
||||
new_subscription(_Nidx, _Owner, Sub, SubState) ->
|
||||
%%SubId = pubsub_subscription:add_subscription(Owner, Nidx, []),
|
||||
SubId = pubsub_subscription:make_subid(),
|
||||
Subs = SubState#pubsub_state.subscriptions,
|
||||
set_state(SubState#pubsub_state{subscriptions = [{Sub, SubId} | Subs]}),
|
||||
{Sub, SubId}.
|
||||
|
||||
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}
|
||||
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
||||
SubId =/= Sid],
|
||||
|
@ -57,7 +57,7 @@
|
||||
encode_host/1]).
|
||||
|
||||
init(_Host, _ServerHost, _Opts) ->
|
||||
pubsub_subscription_odbc:init(),
|
||||
%%pubsub_subscription_odbc:init(),
|
||||
ok.
|
||||
|
||||
terminate(_Host, _ServerHost) ->
|
||||
@ -95,7 +95,7 @@ delete_node(Nodes) ->
|
||||
{result, {default, broadcast, Reply}}.
|
||||
|
||||
subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
SendLast, PresenceSubscription, RosterGroup, Options) ->
|
||||
SendLast, PresenceSubscription, RosterGroup, _Options) ->
|
||||
SubKey = jid:tolower(Subscriber),
|
||||
GenKey = jid:remove_resource(SubKey),
|
||||
Authorized = jid:tolower(jid:remove_resource(Sender)) == GenKey,
|
||||
@ -131,16 +131,26 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
|
||||
%% % Requesting entity is anonymous
|
||||
%% {error, ?ERR_FORBIDDEN};
|
||||
true ->
|
||||
{result, SubId} = pubsub_subscription_odbc:subscribe_node(Subscriber, Nidx, Options),
|
||||
NewSub = case AccessModel of
|
||||
authorize -> pending;
|
||||
_ -> subscribed
|
||||
%%{result, SubId} = pubsub_subscription_odbc:subscribe_node(Subscriber, Nidx, Options),
|
||||
{NewSub, SubId} = case Subscriptions of
|
||||
[{subscribed, Id}|_] ->
|
||||
{subscribed, Id};
|
||||
[] ->
|
||||
Id = pubsub_subscription_odbc:make_subid(),
|
||||
Sub = case AccessModel of
|
||||
authorize -> pending;
|
||||
_ -> subscribed
|
||||
end,
|
||||
update_subscription(Nidx, SubKey, [{Sub, Id} | Subscriptions]),
|
||||
{Sub, Id}
|
||||
end,
|
||||
update_subscription(Nidx, SubKey, [{NewSub, SubId} | Subscriptions]),
|
||||
case {NewSub, SendLast} of
|
||||
{subscribed, never} -> {result, {default, subscribed, SubId}};
|
||||
{subscribed, _} -> {result, {default, subscribed, SubId, send_last}};
|
||||
{_, _} -> {result, {default, pending, SubId}}
|
||||
{subscribed, never} ->
|
||||
{result, {default, subscribed, SubId}};
|
||||
{subscribed, _} ->
|
||||
{result, {default, subscribed, SubId, send_last}};
|
||||
{_, _} ->
|
||||
{result, {default, pending, SubId}}
|
||||
end
|
||||
end.
|
||||
|
||||
@ -200,7 +210,7 @@ unsubscribe_node(Nidx, Sender, Subscriber, SubId) ->
|
||||
|
||||
delete_subscription(SubKey, Nidx, {Subscription, SubId}, Affiliation, Subscriptions) ->
|
||||
NewSubs = Subscriptions -- [{Subscription, SubId}],
|
||||
pubsub_subscription_odbc:unsubscribe_node(SubKey, Nidx, SubId),
|
||||
%%pubsub_subscription_odbc:unsubscribe_node(SubKey, Nidx, SubId),
|
||||
case {Affiliation, NewSubs} of
|
||||
{none, []} -> del_state(Nidx, SubKey);
|
||||
_ -> update_subscription(Nidx, SubKey, NewSubs)
|
||||
@ -497,14 +507,15 @@ replace_subscription(_, [], Acc) -> Acc;
|
||||
replace_subscription({Sub, SubId}, [{_, SubId} | T], Acc) ->
|
||||
replace_subscription({Sub, SubId}, T, [{Sub, SubId} | Acc]).
|
||||
|
||||
new_subscription(Nidx, Owner, Subscription, SubState) ->
|
||||
{result, SubId} = pubsub_subscription_odbc:subscribe_node(Owner, Nidx, []),
|
||||
new_subscription(_Nidx, _Owner, Subscription, SubState) ->
|
||||
%%{result, SubId} = pubsub_subscription_odbc:subscribe_node(Owner, Nidx, []),
|
||||
SubId = pubsub_subscription_odbc:make_subid(),
|
||||
Subscriptions = [{Subscription, SubId} | SubState#pubsub_state.subscriptions],
|
||||
set_state(SubState#pubsub_state{subscriptions = Subscriptions}),
|
||||
{Subscription, SubId}.
|
||||
|
||||
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}
|
||||
|| {S, Sid} <- SubState#pubsub_state.subscriptions,
|
||||
SubId =/= Sid],
|
||||
|
@ -27,6 +27,7 @@
|
||||
%% API
|
||||
-export([init/0, subscribe_node/3, unsubscribe_node/3,
|
||||
get_subscription/3, set_subscription/4,
|
||||
make_subid/0,
|
||||
get_options_xform/2, parse_options_xform/1]).
|
||||
|
||||
% Internal function also exported for use in transactional bloc from pubsub plugins
|
||||
|
@ -27,6 +27,7 @@
|
||||
%% API
|
||||
-export([init/0, subscribe_node/3, unsubscribe_node/3,
|
||||
get_subscription/3, set_subscription/4,
|
||||
make_subid/0,
|
||||
get_options_xform/2, parse_options_xform/1]).
|
||||
|
||||
-include("pubsub.hrl").
|
||||
|
@ -839,15 +839,6 @@ pubsub(Config) ->
|
||||
[#pubsub_affiliation{node = Node, type = owner}]}]} =
|
||||
send_recv(Config, #iq{type = get, to = pubsub_jid(Config),
|
||||
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"
|
||||
#iq{type = result,
|
||||
sub_els = [#pubsub{items = #pubsub_items{
|
||||
|
Loading…
Reference in New Issue
Block a user