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

PubSub: Check for node subscription of bare JID

Don't just check whether the full JID is subscribed when a node
subscription is required to list or publish items.  If the bare JID is
subscribed, these requests are now also accepted.
This commit is contained in:
Holger Weiss 2015-06-19 00:50:08 +02:00
parent 1cf2dfe63a
commit 04038c01f7

View File

@ -373,7 +373,8 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload) ->
end, end,
Affiliation = GenState#pubsub_state.affiliation, Affiliation = GenState#pubsub_state.affiliation,
Subscribed = case PublishModel of Subscribed = case PublishModel of
subscribers -> is_subscribed(SubState#pubsub_state.subscriptions); subscribers -> is_subscribed(GenState#pubsub_state.subscriptions) orelse
is_subscribed(SubState#pubsub_state.subscriptions);
_ -> undefined _ -> undefined
end, end,
if not ((PublishModel == open) or if not ((PublishModel == open) or
@ -738,8 +739,10 @@ get_items(Nidx, JID, AccessModel, PresenceSubscription, RosterGroup, _SubId, _RS
GenState = get_state(Nidx, GenKey), GenState = get_state(Nidx, GenKey),
SubState = get_state(Nidx, SubKey), SubState = get_state(Nidx, SubKey),
Affiliation = GenState#pubsub_state.affiliation, Affiliation = GenState#pubsub_state.affiliation,
Subscriptions = SubState#pubsub_state.subscriptions, BareSubscriptions = GenState#pubsub_state.subscriptions,
Whitelisted = can_fetch_item(Affiliation, Subscriptions), FullSubscriptions = SubState#pubsub_state.subscriptions,
Whitelisted = can_fetch_item(Affiliation, BareSubscriptions) orelse
can_fetch_item(Affiliation, FullSubscriptions),
if %%SubId == "", ?? -> if %%SubId == "", ?? ->
%% Entity has multiple subscriptions to the node but does not specify a subscription ID %% Entity has multiple subscriptions to the node but does not specify a subscription ID
%{error, ?ERR_EXTENDED(?ERR_BAD_REQUEST, "subid-required")}; %{error, ?ERR_EXTENDED(?ERR_BAD_REQUEST, "subid-required")};