24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-12 21:52:07 +02:00

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

View File

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