chadtmiller.com/group-host
atmosphere group host
0
0
The host no longer lists its groups
crates/group-host/src/group_api.rs+0−55
| @@ -405,58 +405,3 @@ fn accepted(host: &Host, members: &str, did: &str) -> anyhow::Result<bool> { | ||
let writers = host.store.writers(members, None, u32::MAX)?; | ||
Ok(writers.iter().any(|w| w.did == did && w.data != empty)) | ||
} | ||
| ||
/// Every group here: to someone signed in, its handle and spaces, and for | ||
/// one whose meta anyone signed in may read, its profile and rules; to no | ||
/// one signed in, each one's DID and handle alone. | ||
pub async fn list_groups(State(host): State<Arc<Host>>, headers: HeaderMap) -> Answer { | ||
let me = caller(&host, &headers, &format!("{NS}.listGroups")).await?; | ||
let mut groups = Vec::new(); | ||
let mut cursor: Option<String> = None; | ||
loop { | ||
let page = host | ||
.store | ||
.accounts(cursor.as_deref(), 100) | ||
.map_err(XrpcError::internal)?; | ||
for (did, _) in &page { | ||
let Ok(handle) = group_of(&host, did) else { | ||
continue; | ||
}; | ||
if me.is_none() { | ||
groups.push(signed_out(did, handle)); | ||
continue; | ||
} | ||
let mut view = base(&host, did, &handle)?; | ||
if host.deactivation(did)?.is_some() { | ||
view["deactivated"] = json!(true); | ||
groups.push(view); | ||
continue; | ||
} | ||
let meta = meta_space(did); | ||
let access = host | ||
.group_record(did, &meta, &format!("{NS}.access"), "self") | ||
.map_err(XrpcError::internal)?; | ||
if access.is_some_and(|a| Access::of(&a, &meta).public) { | ||
let profile = host | ||
.group_record(did, &meta, &format!("{NS}.profile"), "self") | ||
.map_err(XrpcError::internal)?; | ||
if let Some(profile) = profile { | ||
merge(&mut view, profile_view(&profile)); | ||
} | ||
view["rules"] = rules(&host, did)? | ||
.into_iter() | ||
.map(|mut r| { | ||
r.as_object_mut().map(|o| o.remove("createdAt")); | ||
r | ||
}) | ||
.collect(); | ||
} | ||
groups.push(view); | ||
} | ||
if page.len() < 100 { | ||
break; | ||
} | ||
cursor = page.last().map(|(did, _)| did.clone()); | ||
} | ||
Ok(Json(json!({ "groups": groups }))) | ||
} | ||
crates/group-host/src/lexicons.rs+0−1
| @@ -74,7 +74,6 @@ pub const FILES: &[&str] = &[ | ||
lexicon!("fyi/opensocial/leaveGroup"), | ||
lexicon!("fyi/opensocial/listAppPasswords"), | ||
lexicon!("fyi/opensocial/listConnectedApps"), | ||
lexicon!("fyi/opensocial/listGroups"), | ||
lexicon!("fyi/opensocial/listGroupTokens"), | ||
lexicon!("fyi/opensocial/listInvites"), | ||
lexicon!("fyi/opensocial/listJoinRequests"), | ||
crates/group-host/src/lib.rs+0−4
| @@ -213,10 +213,6 @@ pub fn router(host: Arc<Host>) -> Router { | ||
"/xrpc/fyi.opensocial.listMembers", | ||
get(group_api::list_members), | ||
) | ||
.route( | ||
"/xrpc/fyi.opensocial.listGroups", | ||
get(group_api::list_groups), | ||
) | ||
.route( | ||
"/xrpc/fyi.opensocial.deactivateGroup", | ||
post(group_lifecycle::deactivate_group), | ||
crates/group-host/tests/groups.rs+0−68
| @@ -358,74 +358,6 @@ async fn its_access_records_say_who_reads_and_writes_its_spaces() { | ||
); | ||
} | ||
| ||
#[tokio::test] | ||
async fn lists_every_group_here() { | ||
let h = start(&[], false).await; | ||
let [alice, _, dave] = people(&h).await; | ||
let open = start_group( | ||
&h, | ||
&alice, | ||
json!({"handle": RIDERS, "displayName": "Riders"}), | ||
) | ||
.await; | ||
h.host | ||
.space_write( | ||
&open, | ||
&meta_space(&open), | ||
&[rule_at("a", "Be kind", None, "2026-11-03T00:00:00Z")], | ||
) | ||
.await | ||
.unwrap(); | ||
let closed = start_group( | ||
&h, | ||
&alice, | ||
json!({"handle": "hikers.groups.test", "displayName": "Hikers", "metaReadableBy": [{"role": "member"}]}), | ||
) | ||
.await; | ||
// An account that is no group is not listed. | ||
h.host.create_account("plain.groups.test").await.unwrap(); | ||
// To someone signed in, a member of neither: the profile and rules of | ||
// the one whose meta anyone signed in may read. | ||
let lxm = format!("{NS}.listGroups"); | ||
let (status, listed) = get(&h, &lxm, "", &[auth(&h, &dave, &lxm)]).await; | ||
assert_eq!(status, 200); | ||
let groups = listed["groups"].as_array().unwrap(); | ||
assert_eq!(groups.len(), 2); | ||
let of = |did: &str| groups.iter().find(|g| g["did"] == did).unwrap().clone(); | ||
assert_eq!(of(&open)["displayName"], "Riders"); | ||
assert_eq!( | ||
of(&open)["rules"], | ||
json!([{"rkey": "a", "title": "Be kind", "text": ""}]) | ||
); | ||
assert_eq!(of(&closed).get("displayName"), None); | ||
assert_eq!(of(&closed)["handle"], "hikers.groups.test"); | ||
// To no one signed in, each by its DID and handle alone. | ||
let (status, listed) = get(&h, &lxm, "", &[]).await; | ||
assert_eq!(status, 200); | ||
let mut groups = listed["groups"].as_array().unwrap().clone(); | ||
groups.sort_by_key(|g| g["handle"].as_str().unwrap().to_string()); | ||
assert_eq!( | ||
groups, | ||
[ | ||
json!({"did": closed, "handle": "hikers.groups.test"}), | ||
json!({"did": open, "handle": RIDERS}), | ||
] | ||
); | ||
} | ||
| ||
#[tokio::test] | ||
async fn lists_groups_past_a_page() { | ||
let h = start(&[], false).await; | ||
for i in 0..101 { | ||
h.host | ||
.create_account(&format!("a{i:03}.groups.test")) | ||
.await | ||
.unwrap(); | ||
} | ||
let (status, listed) = get(&h, &format!("{NS}.listGroups"), "", &[]).await; | ||
assert_eq!((status, listed), (200, json!({"groups": []}))); | ||
} | ||
| ||
#[tokio::test] | ||
async fn refuses_a_group_it_should_not_start() { | ||
let h = start(&[], false).await; | ||
crates/group-host/tests/lifecycle.rs+0−5
| @@ -153,12 +153,7 @@ async fn a_group_switched_off_is_read_by_nobody() { | ||
let (_, shown) = get(&h, &lxm, &format!("group={did}"), &[auth(&h, &alice, &lxm)]).await; | ||
assert_eq!(shown["group"]["deactivated"], true); | ||
assert_eq!(shown["group"].get("displayName"), None); | ||
let lxm = format!("{NS}.listGroups"); | ||
let (_, listed) = get(&h, &lxm, "", &[auth(&h, &alice, &lxm)]).await; | ||
assert_eq!(listed["groups"][0]["deactivated"], true); | ||
// To no one signed in, as any other: its DID and handle. | ||
let (_, listed) = get(&h, &lxm, "", &[]).await; | ||
assert_eq!(listed["groups"][0].get("deactivated"), None); | ||
let (_, shown) = get(&h, &format!("{NS}.getGroup"), &format!("group={did}"), &[]).await; | ||
assert_eq!(shown["group"].get("deactivated"), None); | ||
| ||
docs/design/groups.md+6−8
| @@ -117,9 +117,9 @@ Details: | ||
## What each person sees, and finding a group | ||
| ||
Someone not signed in learns of a group only what anyone can already | ||
learn of it from its DID document: its DID and handle. `getGroup` and | ||
`listGroups` tell them that and nothing more, whatever the group's access | ||
records say, since `public` means anyone signed in. | ||
learn of it from its DID document: its DID and handle. `getGroup` tells | ||
them that and nothing more, whatever the group's access records say, | ||
since `public` means anyone signed in. | ||
| ||
`getGroup` gives more to those allowed more. Everyone signed in gets the | ||
group's DID, handle, address, and the URIs of its two spaces. Whoever may | ||
| @@ -135,11 +135,9 @@ switched-off group shows only the first part and `deactivated: true`. | ||
A group that wants to be found says so with its declaration, a | ||
`fyi.opensocial.declaration` record in its public repo pointing at | ||
`meta`. The host writes it when `public` is among `meta`'s readers and | ||
removes it when not. `listGroups` lists every group on the host to | ||
someone signed in, adding the profile and rules of those whose `meta` is | ||
readable by `public`. A hidden group still appears with its DID, handle, | ||
address and space URIs. To someone not signed in, it lists each group by | ||
its DID and handle alone. | ||
removes it when not. The host keeps no list of its groups for people to | ||
browse: how groups are found across the network is still to be decided, | ||
and the declaration is what such a list would read. | ||
| ||
`getActorGroups` lists the switched-on groups a person is in that the | ||
caller is in too, with each group's member count, and its display name and | ||
docs/reference/api.md+0−1
| @@ -53,7 +53,6 @@ spaces through the atproto methods below. | ||
| --- | --- | | ||
| `POST fyi.opensocial.createGroup` | starts a group, the caller its founder and first admin | | ||
| `GET fyi.opensocial.getGroup` | a group as the caller may see it: its profile and rules, and to a member who may read them how many members it has, its roles and spaces; to someone not signed in, its DID and handle alone | | ||
| `GET fyi.opensocial.listGroups` | the groups hosted here, to anyone; to someone signed in, the profile and rules of those anyone signed in may read, and to someone not, each by its DID and handle alone | | ||
| `GET fyi.opensocial.checkAddress` | whether an address, one label under `HANDLE_DOMAIN`, is free for a new group; anyone may ask | | ||
| `GET fyi.opensocial.checkGroupHandle` | whether a domain names the group yet, to be its handle | | ||
| `POST fyi.opensocial.updateGroupHandle` | gives the group a handle on its own domain, or its address back | | ||
harness/e2e/flows.spec.mjs+8−6
| @@ -288,12 +288,14 @@ test("giving a group a picture, and taking it away", async () => { | ||
}) | ||
| ||
test("hiding a group's profile, and showing it again", async () => { | ||
// The host lists every group of its own to someone signed in, as bob | ||
// is, a member of none; a hidden one by its handle alone. | ||
const listed = async () => { | ||
const { groups } = await bob.evaluate(() => fetch('/xrpc/fyi.opensocial.listGroups').then((r) => r.json())) | ||
return groups.find((g) => g.handle === 'hikers.groups.test')?.displayName !== undefined | ||
} | ||
// Found on the network while its declaration is in its public repo, | ||
// which anyone may read. | ||
const listed = async () => | ||
bob.evaluate(async () => { | ||
const { did } = await fetch('/xrpc/com.atproto.identity.resolveHandle?handle=hikers.groups.test').then((r) => r.json()) | ||
const res = await fetch(`/xrpc/com.atproto.repo.getRecord?repo=${did}&collection=fyi.opensocial.declaration&rkey=self`) | ||
return res.ok | ||
}) | ||
expect(await listed()).toBe(true) | ||
await page.goto(url('/g/hikers.groups.test/settings')) | ||
// Saved, and the page opened afresh as the host has it: not reloaded, | ||
lexicons/fyi/opensocial/listGroups.jsondeleted+0−30
| @@ -1,30 +0,0 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "fyi.opensocial.listGroups", | ||
"defs": { | ||
"main": { | ||
"type": "query", | ||
"description": "Host-level: the groups hosted here. With auth, the profiles anyone signed in may read; without it, each group's did and handle alone.", | ||
"parameters": { | ||
"type": "params", | ||
"properties": {} | ||
}, | ||
"output": { | ||
"encoding": "application/json", | ||
"schema": { | ||
"type": "object", | ||
"required": ["groups"], | ||
"properties": { | ||
"groups": { | ||
"type": "array", | ||
"items": { | ||
"type": "ref", | ||
"ref": "fyi.opensocial.defs#groupView" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
web/src/lib/organisms/GroupList.svelte+1−1
| @@ -9,5 +9,5 @@ | ||
{#if groups.length} | ||
<div class="group-list">{#each groups as g (g.did)}<GroupRow name={g.displayName ?? g.handle} handle={g.handle} avatar={image(g.did, g.avatar)} />{/each}</div> | ||
{:else} | ||
<Empty title="No groups here yet">A group started on this host shows here once its profile is public.</Empty> | ||
<Empty title="No groups yet">Start one, or join one you are invited to.</Empty> | ||
{/if} | ||