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

Groups invite people into their inboxes, and invites admit them

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

What changes

Groups invite people into their inboxes, and invites admit them. These are new methods in group_invites.rs:

  • fyi.opensocial.createInvite (needs invite) writes an invite in the group's own repo in the invitee's inbox. The inbox (at://<invitee>/space/fyi.opensocial.inbox/self) is a space under their DID, at their PDS.
    • The write reaches their PDS as any write to a space elsewhere does, owed until it lands.
    • It takes words and an expiresAt. A member gets AlreadyMember, and an invite already waiting is the one answered.
  • fyi.opensocial.listInvites (needs invite) lists those waiting, newest first, a page at a time, leaving lapsed ones out.
  • fyi.opensocial.revokeInvite (needs invite, by URI) and fyi.opensocial.declineInvite (the invitee's own) take the record out of the inbox and the host's list. The group may invite them again.
  • fyi.opensocial.getActorInvites returns the caller's own waiting invites from the groups here, with each group's name and face. It skips switched-off groups and can be limited to one group.
  • requestJoin redeems an invite whatever the join policy: the asker is admitted with the default roles, and any request of theirs is cleared.
  • com.atproto.managedspace.checkUserAccess answers an inbox's authority, with service auth from it, for this host as the inbox's managing app. Its owner reads it, and only groups here write in it.

The host keeps its own list of what it sent in a new invite table: it redeems invites, since the inbox is its owner's to read, not the group's. Lexicons gain AlreadyMember (createInvite, admitMember, the latter from the joining pull's review) and InviteNotFound (revokeInvite). docs/design/membership.md gains "Invites", and step 5 is done in the plan.

Why

This is step 5's last part, following the prototype's methods/invites.ts and checkUserAccess.ts. It changes these:

  • Who writes in an inbox: only groups on this host, where the prototype let anyone write there and invited spam.
  • Delivery: the group's write goes through the space outbox rather than being caught and deferred.
  • expiresAt is kept to.
  • Redeeming also clears a waiting request.

How it was checked

  • tests/invites.rs:

    • An invite written: the record in the group's repo in the inbox; the invitee's PDS told; asked again returning the same one.
    • Listing: paging, an expiresAt echoed, and the invitee's own list.
    • Redeeming: into an invite-only group, the invite taken back, a stale request cleared.
    • Every refusal: a member, a bad invitee, a bad expiresAt (checked before an invite already waiting is returned), a non-inviter, a bad cursor.
    • Taking back: revoked (then not found, malformed), declined (then not found), lapsed (not listed, not redeemed), a switched-off group's invites not shown, and the group's avatar shown.
    • checkUserAccess:
      • writes by a group allowed; by a stranger or a non-group account refused;
      • reads by the owner allowed, by others refused;
      • a non-inbox space refused;
      • a non-authority asker refused, a malformed space refused, no auth refused.
    • The datetime reader, against known instants and eight malformed forms.
  • tests/interop.rs adds an_invite_into_an_inbox_on_the_reference_pds, against the alpha in CI:

    1. Alice makes her inbox on the reference PDS, a managedspace naming this host.
    2. A group here invites her.
    3. Her PDS asks this host's checkUserAccess, takes the write (nothing stays owed), and lists the group among her inbox's writers.

    This needs a host whose did:web the reference resolves, so a start_reachable_by_name serves at http://localhost:<port>, listening on [::]. This runs only in CI.

  • just cov is at 100% of lines and functions. Clippy and just lex are clean.

Shortcomings

  • Making someone's inbox is their app's to do. Until they have one, their PDS refuses the group's write, and the outbox gives up after a day; the host's list still redeems the invite.
  • An inbox isn't rate-limited per group.

🤖 Generated with Claude Code

Asked for changes

This adds the invite methods, the invite table, redeeming through requestJoin, and checkUserAccess. I read group_invites.rs, group_join.rs and the store's invite functions. I did not read the tests, lexicons or docs, or run the checks.

One bug needs fixing. create_invite returns any row from store.invited, and the store comment says that includes lapsed invites. Nothing removes a lapsed row except revoke, decline or redeem, and redeem ignores lapsed ones. So once an invite with an expiresAt lapses, inviting that person again returns the dead URI. The group is stuck until someone revokes by hand, which the lapsed invite no longer shows in listInvites, so a revoker would have to know its URI. Treat a lapsed invite as absent here: take it back and write a fresh one, or replace it. A test for re-inviting after a lapse is missing.

Smaller point, optional: millis_of accepts some malformed forms. A fraction like +5 parses, and so does a year like +2026. It does not reject day 31 in a 30-day month either. The 8 malformed cases in the tests may not cover these.

crates/group-host/src/group_invites.rsline 155Outdated

These lines can no longer be read.

review.knotless.dev

invited returns lapsed invites too, so a lapsed invite is answered here as if it still waited, and the invitee can never be re-invited unless the group revokes it by URI. Ignore a lapsed row: take it back and write a new invite.

Changed:

  • createInvite treats a lapsed invite as absent: it takes it back (out of the inbox and the list) and writes a fresh one. A test re-invites after a lapse, sees the fresh URI listed, and redeems it.
  • millis_of is strict: digits alone, a four-digit year and two-digit fields; each month its own length, February by the leap year rule. Tests cover +026, .+5, 11-31, 2026-02-29, 1900-02-29, a one-digit month and a non-digit fraction, and that 2024-02-29 reads.
Approved

The earlier bug is fixed. create_invite now treats a lapsed invite as absent. It takes the old one back with take_back and writes a fresh invite. The tests re-invite after a revoke and check that a fresh invite is listed and admits. I didn't re-read millis_of, which was only an optional point before, and I didn't run the checks.

Merged as bb6ea52