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

Groups are started and joined from the console

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:host/group-page
docs/design/README.md+6−4
@@ -109,10 +109,12 @@ says otherwise.
(`console_login.rs`; done).
7. **The console.** Signing in as oneself (step 6); who is looking
(`getViewer`, as knotless's) and their groups (`getActorGroups`), on
home, and approving an app (`/authorize`; `actors.rs`; done); then
starting a group, a group's page (members, roles, invites, requests,
apps), a person's sessions and app passwords: the console's pages in
`apps/web/src/pages`.
home, and approving an app (`/authorize`; `actors.rs`; done);
starting a group (`/new`) and a group's page (`/g/<handle>`: its
profile and rules, joining and leaving, its members, and admitting
those asking; done); then running a group from its page (roles,
invites, its apps and app passwords): the console's pages in
`apps/web/src/pages`. Each is used end to end in `harness/e2e`.
8. **Moderation, recovery and moving.** Reports, labels, subjects and
history; recovery keys; importing an account; migrating a group to
another host and moving the host itself:
harness/e2e/flows.spec.mjs+42−2
@@ -3,18 +3,22 @@
// and what the app then does as the group, read back from the host.
import { expect, test } from '@playwright/test'
import { App, signIn, signedInAs, url, world } from './pages.mjs'
import { App, signIn, signedInAs, url, who, world } from './pages.mjs'
test.describe.configure({ mode: 'serial' })
let page
// Bob's browser, apart from alice's.
let bob
test.beforeAll(async ({ browser }) => {
page = await browser.newPage()
bob = await (await browser.newContext()).newPage()
})
test.afterAll(async () => {
await page.close()
await bob.context().close()
})
test('signing in at her own PDS', async () => {
@@ -29,11 +33,47 @@ test('seeing her groups', async () => {
await expect(page.locator('.group-row', { hasText: 'Riders' }).first()).toBeVisible()
})
test('starting a group', async () => {
await page.getByRole('link', { name: 'Start a group' }).click()
await page.getByRole('textbox', { name: 'Handle' }).fill('hikers.groups.test')
await page.getByRole('textbox', { name: 'Name' }).fill('Hikers')
await page.getByRole('textbox', { name: 'What it is for' }).fill('Walks on Sundays.')
await page.getByRole('button', { name: 'Start the group' }).click()
await page.waitForURL(url('/g/hikers.groups.test'))
await expect(page.getByRole('heading', { name: 'Hikers' })).toBeVisible()
await expect(page.getByText('Walks on Sundays.')).toBeVisible()
await expect(page.getByText('You are a member.')).toBeVisible()
// A handle taken already is the form's to say.
await page.goto(url('/new'))
await page.getByRole('textbox', { name: 'Handle' }).fill('hikers.groups.test')
await page.getByRole('textbox', { name: 'Name' }).fill('Hikers again')
await page.getByRole('button', { name: 'Start the group' }).click()
await expect(page.locator('.danger')).toBeVisible()
})
test('asking to join, and being admitted', async () => {
await bob.goto(url('/g/hikers.groups.test'))
await signIn(bob, 'bob')
await bob.getByRole('button', { name: 'Ask to join' }).click()
await expect(bob.getByText('You have asked to join.')).toBeVisible()
await page.goto(url('/g/hikers.groups.test'))
const asking = page.locator('.requests li', { hasText: who.bob.did })
await asking.getByRole('button', { name: 'Admit' }).click()
await expect(page.locator('.members', { hasText: who.bob.did })).toBeVisible()
await bob.reload()
await expect(bob.getByText('You are a member.')).toBeVisible()
})
test('leaving a group', async () => {
await bob.getByRole('button', { name: 'Leave' }).click()
await expect(bob.getByRole('button', { name: 'Ask to join' })).toBeVisible()
})
test('signing an app in as her group', async () => {
const app = await new App('atproto repo:app.bsky.feed.post').listen()
await page.goto(await app.push())
await expect(page.getByRole('heading', { name: 'Sign in an app' })).toBeVisible()
await expect(page.getByText('repo:app.bsky.feed.post')).toBeVisible()
await expect(page.getByText('repo:app.bsky.feed.post').first()).toBeVisible()
await page.getByRole('button', { name: 'Sign it in as Riders' }).click()
const back = await app.back
app.close()
lexicons/upstream/com/atproto/identity/resolveHandle.jsonnew+37−0
@@ -0,0 +1,37 @@
{
"lexicon": 1,
"id": "com.atproto.identity.resolveHandle",
"defs": {
"main": {
"type": "query",
"description": "Resolves an atproto handle (hostname) to a DID. Does not necessarily bi-directionally verify against the the DID document.",
"parameters": {
"type": "params",
"required": ["handle"],
"properties": {
"handle": {
"type": "string",
"format": "handle",
"description": "The handle to resolve."
}
}
},
"output": {
"encoding": "application/json",
"schema": {
"type": "object",
"required": ["did"],
"properties": {
"did": { "type": "string", "format": "did" }
}
}
},
"errors": [
{
"name": "HandleNotFound",
"description": "The resolution process confirmed that the handle does not resolve to any DID."
}
]
}
}
}
web/src/lib/molecules/GroupRow.svelte+2−2
@@ -1,13 +1,13 @@
<script lang="ts">
import Avatar from '#lib/atoms/Avatar.svelte';
/** A group in a list: its picture, its name, and its handle. */
/** A group in a list: its picture, its name (a link to its page), and its handle. */
let { name, handle, avatar }: { name: string; handle: string; avatar?: string | null } = $props();
</script>
<div class="group-row">
<Avatar src={avatar} size="md" />
<div>
<div>{name}</div>
<div><a href={`/g/${handle}`}>{name}</a></div>
<div class="mute mono">@{handle}</div>
</div>
</div>
web/src/lib/molecules/Standing.sveltenew+25−0
@@ -0,0 +1,25 @@
<script lang="ts">
/**
* Where the person looking stands with the group, and what they can do
* about it: join or ask to, take back their request, or leave.
*/
let {
member,
asked,
joinPolicy
}: { member: boolean; asked: boolean; joinPolicy?: string } = $props();
const invited = $derived(joinPolicy?.endsWith('invite'));
const open = $derived(joinPolicy?.endsWith('open'));
</script>
<div class="standing">
{#if member}
<form method="post" action="?/leave"><span class="mute">You are a member.</span> <button type="submit">Leave</button></form>
{:else if asked}
<form method="post" action="?/cancel"><span class="mute">You have asked to join.</span> <button type="submit">Take back the request</button></form>
{:else if invited}
<p class="mute">This group takes people by invitation.</p>
{:else}
<form method="post" action="?/join"><button type="submit">{open ? 'Join' : 'Ask to join'}</button></form>
{/if}
</div>
web/src/lib/organisms/GroupProfile.sveltenew+19−0
@@ -0,0 +1,19 @@
<script lang="ts">
/** A group as its profile says: its words, and its rules in order. */
let {
description,
rules = []
}: { description?: string; rules?: { rkey: string; title: string; text?: string }[] } = $props();
</script>
<div class="stack">
{#if description}<p>{description}</p>{/if}
{#if rules.length}
<h2>Rules</h2>
<ol>
{#each rules as r (r.rkey)}
<li><strong>{r.title}</strong>{#if r.text}<p class="mute">{r.text}</p>{/if}</li>
{/each}
</ol>
{/if}
</div>
web/src/lib/organisms/JoinRequests.sveltenew+20−0
@@ -0,0 +1,20 @@
<script lang="ts">
import Empty from '#lib/molecules/Empty.svelte';
/** The requests waiting to join, for a member who may admit them: each admitted or turned down. */
let { requests }: { requests: { did: string; message?: string; actor?: { did: string; handle?: string } }[] } = $props();
</script>
{#if requests.length}
<ul class="requests">
{#each requests as r (r.did)}
<li class="stack">
<span class="mono">{r.actor?.handle ? `@${r.actor.handle}` : r.did}</span>
{#if r.message}<p>{r.message}</p>{/if}
<form method="post" action="?/admit"><input type="hidden" name="did" value={r.did} /><button type="submit">Admit</button></form>
<form method="post" action="?/deny"><input type="hidden" name="did" value={r.did} /><button type="submit">Turn down</button></form>
</li>
{/each}
</ul>
{:else}
<Empty title="Nobody is waiting to join" />
{/if}
web/src/lib/organisms/MemberList.sveltenew+15−0
@@ -0,0 +1,15 @@
<script lang="ts">
import Empty from '#lib/molecules/Empty.svelte';
/** Who is in the group, and their roles. */
let { members }: { members: { actor: { did: string; handle?: string }; roles: { role: string }[] }[] } = $props();
</script>
{#if members.length}
<ul class="members">
{#each members as m (m.actor.did)}
<li><span class="mono">{m.actor.handle ? `@${m.actor.handle}` : m.actor.did}</span> <span class="mute">{m.roles.map((r) => r.role).join(', ')}</span></li>
{/each}
</ul>
{:else}
<Empty title="No members yet" />
{/if}
web/src/lib/organisms/NewGroupForm.sveltenew+23−0
@@ -0,0 +1,23 @@
<script lang="ts">
/**
* Starting a group: its handle, its name and words, and how people get
* in. `failed` is what the host said of the last try, if it refused it.
*/
let { failed }: { failed?: string } = $props();
</script>
<form class="stack" method="post">
{#if failed}<p class="danger">{failed}</p>{/if}
<label class="field">Handle <input name="handle" required placeholder="riders.example.com" /></label>
<label class="field">Name <input name="displayName" required maxlength="64" /></label>
<label class="field">What it is for <textarea name="description" maxlength="300"></textarea></label>
<label class="field">
How people join
<select name="joinPolicy">
<option value="approval">They ask, and a member who may admits them</option>
<option value="open">Anyone signed in, at once</option>
<option value="invite">Only by invitation</option>
</select>
</label>
<button type="submit">Start the group</button>
</form>
web/src/routes/g/[handle]/+page.server.tsnew+48−0
@@ -0,0 +1,48 @@
import type * as resolveHandle from '#lib/lexicons/com/atproto/identity/resolveHandle.ts';
import type * as getGroup from '#lib/lexicons/fyi/opensocial/getGroup.ts';
import type { Actions, PageServerLoad } from './$types';
import { call, xrpc } from '#lib/data.ts';
type Handle = `${string}.${string}`;
/** The group the page's address names, by its handle: its DID. */
async function groupOf(event: { fetch: typeof fetch; params: { handle?: string } }) {
const handle = (event.params.handle ?? '') as Handle;
const answer = await xrpc<typeof resolveHandle.main>(event, 'com.atproto.identity.resolveHandle', { handle });
return answer.did;
}
/** A group, by its handle, as the person looking may see it. */
export const load: PageServerLoad = async (event) => {
return xrpc<typeof getGroup.main>(event, 'fyi.opensocial.getGroup', { group: await groupOf(event) });
};
/** The group a form on its page is about, and the DID a form names. */
async function asked(event: { fetch: typeof fetch; params: { handle?: string }; request: Request }) {
const form = await event.request.formData();
return { group: await groupOf(event), who: String(form.get('did') ?? '') };
}
/** What a person does on a group's page: each drawn again after. */
export const actions: Actions = {
join: async (event) => {
const { group } = await asked(event);
await call(event, 'fyi.opensocial.requestJoin', { group });
},
cancel: async (event) => {
const { group } = await asked(event);
await call(event, 'fyi.opensocial.cancelJoinRequest', { group });
},
leave: async (event) => {
const { group } = await asked(event);
await call(event, 'fyi.opensocial.leaveGroup', { group });
},
admit: async (event) => {
const { group, who } = await asked(event);
await call(event, 'fyi.opensocial.admitMember', { group, did: who });
},
deny: async (event) => {
const { group, who } = await asked(event);
await call(event, 'fyi.opensocial.denyJoinRequest', { group, member: who });
}
};
web/src/routes/g/[handle]/+page.sveltenew+31−0
web/src/routes/new/+page.server.tsnew+34−0
web/src/routes/new/+page.sveltenew+19−0
web/src/routes/+page.svelte+1−0
web/src/app.css+3−0