chadtmiller.com/group-host
atmosphere group host
0
0
# Joining a group
An app that joins a group for a person, as the person's own app: the side
of a group that [reading a group](../read-a-group/README.md) doesn't see.
Signed in to the person's own PDS, it:
1. makes their inbox, `at:space/<them>/org.atgrp.inbox/self`, a space of
their own that any group may write an invite in and only they read, or
finds the one they have;
2. reads the invite the group wrote there, if it sent one;
3. asks the group's host to let them in (`org.atgrp.requestJoin`), through
their own PDS, which signs the call as them and sends it on;
4. once they're in, confirms the membership with an
`org.atgrp.confirmation` in their own repo in the group's members
space, at their own PDS.
A live invite lets them in whatever the group's join policy. Otherwise a
group that takes requests (`approval`) keeps theirs waiting, with their
message, for its admins, and an `invite`-only group refuses it
(`JoinClosed`).
It is one file, `main.ts`, on atproto's own TypeScript packages, from the
spaces alpha the host runs against:
- `@atproto/oauth-client-node` signs the person in at their own PDS: the
loopback client `http://localhost`, an app on this machine.
- `@atproto/lex` calls the host's `org.atgrp.requestJoin`, typed by the
schemas under `lexicons/` at the top of this repository, sent to the
host's `#atgrp` service through the PDS (the `atproto-proxy` header).
- `@atproto/lex-space` makes the inbox, reads the group's invite there with
a credential their PDS gives for their delegation token, and writes the
confirmation.
[Membership](../../docs/design/membership.md) says what the host does on
its side.
## Running it
It needs Node at the version `.node-version` names, which runs `main.ts`
as it is.
```sh
cd examples/join-a-group
npm install
npm start <your handle> <group handle or DID> [message to the group]
```
It prints a link to the person's PDS. Sign in there and allow the app,
and the browser comes back to it. Asked of a group that takes requests,
with no invite:
```
Signed in as did:plc:atldqeavl57gbxg4q6zrnigb
Made your inbox, where groups write their invites
Asked to join did:plc:fycrfwtr6yn64r3u6afr5dtg: waiting for its admins.
```
and again, once the group has invited them:
```
Signed in as did:plc:atldqeavl57gbxg4q6zrnigb
did:plc:fycrfwtr6yn64r3u6afr5dtg invited you: Ride with us on Sunday.
Joined did:plc:fycrfwtr6yn64r3u6afr5dtg, and confirmed it.
```
An invite sent before the person had an inbox isn't in it, as the host
had nowhere to write it, but the host keeps its own list of invites, so
asking to join is let in all the same. Reading the group afterwards with
[read-a-group](../read-a-group/README.md) shows them as members, confirmed.
What the app asks of the person:
| Scope | For |
| ------------------------------------------------------------------------------------- | ------------------------------------------------------- |
| `space:org.atgrp.inbox?action=read&manage=create` | making their inbox, and reading what groups wrote there |
| `space:org.atgrp.members?authority=*&collection=org.atgrp.confirmation&action=create` | writing their confirmation in any group's members space |
| `rpc:org.atgrp.requestJoin?aud=*` | asking a group's host to let them in |
A group host's own permission set,
`include:org.atgrp.authParticipate`, holds these and the rest of what a
person does in a group (withdrawing a request, leaving, declining an
invite, reporting, appealing), where the person's PDS can read its
lexicon.
### On `just dev`
`just dev` runs a PDS and a host on a network of their own, with a PLC
directory of their own, on http. Name the directory, and the PDS to
resolve handles, from what it prints:
```sh
PLC_URL=<the directory> HANDLE_RESOLVER=<the PDS> npm start alice.test hikers.groups.localtest.me
```
Hikers, bob's group, has invited alice. Signing in as `alice.test` with
the password `password` makes her inbox and lets her in.
## What it leaves out
- The members space type is declared in `main.ts` with `l.space(...)`,
naming the collection it writes, rather than generated: the alpha's
`lex build` makes a space type of several collections that TypeScript
cannot type, so `npm run lex` leaves `org.atgrp.meta` and
`org.atgrp.members` out. Fixed upstream by
[bluesky-social/atproto#6085](https://github.com/bluesky-social/atproto/pull/6085).
- It doesn't name the invite it read (`requestJoin`'s `invite`): a live
invite from the group lets them in without it.
- It leaves the rest of what a person does to the host's methods the
permission set lists: `cancelJoinRequest`, `leaveGroup`,
`org.atgrp.internal.declineInvite`, and the moderation methods.