Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
limit non-local circles as members of local circles
Signed-off-by: Maxence Lange <[email protected]>
  • Loading branch information
ArtificialOwl committed Jul 27, 2021
commit b68d61cc3ced8bbf1221d1b75a5c16d337000eee
6 changes: 6 additions & 0 deletions lib/FederatedItems/SingleMemberAdd.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,12 @@ protected function generateMember(FederatedEvent $event, Circle $circle, Member
throw new FederatedItemBadRequestException(StatusCode::$MEMBER_ADD[125], 125);
}

if ($circle->isConfig(Circle::CFG_LOCAL)
&& $federatedUser->getUserType() === Member::TYPE_CIRCLE
&& !$federatedUser->getBasedOn()->isConfig(Circle::CFG_LOCAL)) {
throw new FederatedItemBadRequestException(StatusCode::$MEMBER_ADD[131], 131);
}

if ($member->getSingleId() === $circle->getSingleId()) {
throw new FederatedItemBadRequestException(StatusCode::$MEMBER_ADD[128], 128);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/StatusCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ class StatusCode {
127 => 'Remote Users are not accepted in a non-federated Circle',
128 => 'Cannot add Circle as its own Member',
129 => 'Member does not contains a patron',
130 => 'Member is invited by an entity that does not belongs to the instance at the origin of the request'
130 => 'Member is invited by an entity that does not belongs to the instance at the origin of the request',
131 => 'Member is a non-local Circle'
];

public static $MEMBER_LEVEL = [
Expand Down