~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

People join a group at once, by request, or not without an invite

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/joining

What changes

People join a group at once, by request, or not without an invite. These are new methods in group_join.rs, by the profile's joinPolicy:

  • open: fyi.opensocial.requestJoin admits at once, with the roles the group marks default (member, unless it marks others).
  • approval: requestJoin keeps a request, with the asker's message.
    • fyi.opensocial.listJoinRequests (needs admit) lists those waiting, newest first, a page at a time.
    • fyi.opensocial.admitMember (needs admit) admits one, with the defaults or the roles named. Each role must be one the admitter may give (NotAssignable): admitting gives roles, so it is bound as assignRoles is.
    • fyi.opensocial.denyJoinRequest (needs admit) turns one down.
    • fyi.opensocial.cancelJoinRequest withdraws one's own, and fyi.opensocial.getJoinRequest returns one's own while it waits.
  • invite: refused with InviteRequired. Invites come next.
  • Asking twice keeps one request. A member asking gets AlreadyMember, and a switched-off group refuses.

getGroup shows a non-member their own waiting request (viewer.request), and shows joinRequests to whoever may admit.

Requests wait in a new join_request table, not in the group's records: who asks is no member, and the members space is for members. A decided request is removed, so one turned down looks the same as one never made.

Members in group_members.rs gains default_roles and put_membership, which assignRoles now uses too. The lexicons gain the errors these methods return. docs/design/membership.md gains "Joining".

Why

This is step 5's second part, following the prototype's requestJoin and methods/join.ts. One change: the prototype kept decided requests, with who decided. Here a decided request is simply removed, which the prototype's own comment says is the point: a denial should look like never having asked. Invite redemption, which runs through requestJoin in the prototype, comes with invites in the next pull.

How it was checked

tests/joining.rs covers:

  • An open group: default roles; roles marked default; member when none is marked; AlreadyMember.
  • An invite-only group: InviteRequired, malformed calls, and a switched-off group.
  • A group that approves:
    • asking twice;
    • each asker's own request, and an outsider's empty one;
    • getGroup for the asker, for admins, and for a member;
    • listing and paging, a non-admitter refused, a bad cursor;
    • admitting with defaults, with named roles, and with a role that isn't the admitter's to give;
    • a non-admitter refused, an already-decided request;
    • denying, then asking again; withdrawing;
    • missing fields.
  • just cov is at 100% of lines and functions. Clippy and just lex are clean.

Shortcomings

  • Requests are not told to anyone as they arrive; the console will show them.
  • An asker gets no word of a decision, other than their request no longer waiting.

🤖 Generated with Claude Code

Asked for changes

This adds joining by joinPolicy: open admits at once, approval queues a request in a new join_request table, and invite is refused. It adds list, admit, deny, cancel and get for requests, and getGroup now shows requests. I found one real bug, and I read only the diff, not the files around it.

admitMember can overwrite an existing member's roles.

  • The only gate on admitMember is that a pending request exists. A request is not removed when its asker becomes a member by another route.
  • For example, assignRoles can add someone who has a pending request. admitMember then calls put_membership for that person, which replaces their roles with the defaults (or the roles named).
  • That replacement skips the keeps_a_configurer check that assignRoles runs. A holder of admit could therefore demote the last configurer, or strip any member's roles.
  • Fix: in admit_member, return AlreadyMember if members.membership(did) is Some, and drop the stale request. Add a test for it.

Smaller points, not blocking:

  • requestJoin stores message without a length bound. I did not check whether the requestJoin lexicon sets maxLength on message, so please confirm it does and that the host enforces it.
  • If roles: [] is passed to admitMember, the person is admitted with no roles. Decide whether that should be allowed.
crates/group-host/src/group_join.rsline 149Outdated

These lines can no longer be read.

review.knotless.dev

A pending request doesn't mean they're a non-member: assignRoles may have added them since. Check members.membership(did) here and refuse with AlreadyMember, or put_membership below overwrites their roles without the keeps_a_configurer check.

Changed:

  • admitMember refuses AlreadyMember when the asker is a member by now, and drops their stale request, so it never replaces anyone's roles. An open group's requestJoin also drops a request made before the group opened. Tests cover both.
  • requestJoin's message is held to the lexicon's maxGraphemes 300 / maxLength 3000, refused past that, with a test.
  • admitMember with roles: [] is refused: an admission gives some role.
Approved

This pull adds joining by joinPolicy. An open group admits at once, an approval group queues the request in the new join_request table, and an invite group refuses with InviteRequired. It also adds the list, admit, deny, cancel and get methods for requests, and getGroup now shows requests. I read the whole diff but not the files around it, and I did not run the tests.

Round 1 asked for three things, and all three are done:

  • admitMember overwriting a member's roles: admit_member now returns AlreadyMember when the person already has a membership, and drops the stale request first. A test covers it.
  • Message length: requestJoin now caps message at 300 characters and 3000 bytes, with a test for 301 characters. I did not check these limits against the lexicon's maxLength.
  • roles: []: it is now rejected with InvalidRequest, with a test.

Not blocking: admitMember can now return AlreadyMember, but admitMember.json does not list it in its errors.

Merged as 0b76a36