Owner can subscribe to its node (#454)

This commit is contained in:
Christophe Romain 2015-04-21 15:14:39 +02:00
parent 747d25b4ad
commit cbd45974e2
2 changed files with 8 additions and 6 deletions

View File

@ -217,6 +217,7 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
(_) -> false
end,
Subscriptions),
Owner = Affiliation == owner,
if not Authorized ->
{error,
?ERR_EXTENDED((?ERR_BAD_REQUEST), <<"invalid-jid">>)};
@ -225,13 +226,13 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
PendingSubscription ->
{error,
?ERR_EXTENDED((?ERR_NOT_AUTHORIZED), <<"pending-subscription">>)};
(AccessModel == presence) and not PresenceSubscription ->
(AccessModel == presence) and (not PresenceSubscription) and (not Owner) ->
{error,
?ERR_EXTENDED((?ERR_NOT_AUTHORIZED), <<"presence-subscription-required">>)};
(AccessModel == roster) and not RosterGroup ->
(AccessModel == roster) and (not RosterGroup) and (not Owner) ->
{error,
?ERR_EXTENDED((?ERR_NOT_AUTHORIZED), <<"not-in-roster-group">>)};
(AccessModel == whitelist) and not Whitelisted ->
(AccessModel == whitelist) and (not Whitelisted) and (not Owner) ->
{error,
?ERR_EXTENDED((?ERR_NOT_ALLOWED), <<"closed-node">>)};
%%MustPay ->

View File

@ -158,6 +158,7 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
(_) -> false
end,
Subscriptions),
Owner = Affiliation == owner,
if not Authorized ->
{error,
?ERR_EXTENDED((?ERR_BAD_REQUEST), <<"invalid-jid">>)};
@ -166,13 +167,13 @@ subscribe_node(Nidx, Sender, Subscriber, AccessModel,
PendingSubscription ->
{error,
?ERR_EXTENDED((?ERR_NOT_AUTHORIZED), <<"pending-subscription">>)};
(AccessModel == presence) and not PresenceSubscription ->
(AccessModel == presence) and (not PresenceSubscription) and (not Owner) ->
{error,
?ERR_EXTENDED((?ERR_NOT_AUTHORIZED), <<"presence-subscription-required">>)};
(AccessModel == roster) and not RosterGroup ->
(AccessModel == roster) and (not RosterGroup) and (not Owner) ->
{error,
?ERR_EXTENDED((?ERR_NOT_AUTHORIZED), <<"not-in-roster-group">>)};
(AccessModel == whitelist) and not Whitelisted ->
(AccessModel == whitelist) and (not Whitelisted) and (not Owner) ->
{error,
?ERR_EXTENDED((?ERR_NOT_ALLOWED), <<"closed-node">>)};
%%MustPay ->