diff options
Diffstat (limited to 'packages/meshbay-hub/src/meshbay_hub/api')
| -rw-r--r-- | packages/meshbay-hub/src/meshbay_hub/api/groups.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/packages/meshbay-hub/src/meshbay_hub/api/groups.py b/packages/meshbay-hub/src/meshbay_hub/api/groups.py index 8283276..6819ff6 100644 --- a/packages/meshbay-hub/src/meshbay_hub/api/groups.py +++ b/packages/meshbay-hub/src/meshbay_hub/api/groups.py @@ -317,17 +317,30 @@ async def create_group( current_user: User = Depends(require_user_scope), db: AsyncSession = Depends(get_db), ): + # Being listed and being open are one question, not two. + # + # A public group that admits nobody is a contradiction: it is in the + # directory, so people find it and then discover they cannot get in. + # Admission by request was considered and dropped — between strangers the + # only channel is the hub, so the one-time code would travel through the + # very party it exists to keep out, and would protect nothing. + # + # The other way round was accepted until now and should not have been: a + # group anyone may join, that nobody can find, is a listing with the listing + # removed. Nothing could reach it but a link, and there is no link — joining + # goes through the node. The create form no longer offers either + # combination; refusing them here is what makes that true of the API too. + if body.visibility == "public" and body.join_policy != "open": + raise HTTPException( + status_code=422, + detail="A public group is open to join. Make it private if you " + "want to choose who comes in.") + if body.visibility != "public" and body.join_policy == "open": + raise HTTPException( + status_code=422, + detail="A private group is invite-only. Make it public if you want " + "anyone to be able to join.") if body.visibility == "public": - # A public group that admits nobody is a contradiction: it is listed in - # the directory, so people find it and then discover they cannot get in. - # Admission by request was considered and dropped — between strangers the - # only channel is the hub, so the one-time code would travel through the - # very party it exists to keep out, and would protect nothing. - if body.join_policy != "open": - raise HTTPException( - status_code=422, - detail="A public group is open to join. Make it private if you " - "want to choose who comes in.") await _check_public_group_quota(db, current_user) desc = (body.description or "")[:512] if body.description else None |