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

A group's profile has the opensocial proposal's fields alone

Merged chadtmiller.com asked to merge into main from chadtmiller.com/group-host:profile/drop-location
.claude/skills/guides/questions.md+1−1
@@ -14,7 +14,7 @@ they might do next.
3. What is the address, and can I change it later?
4. Who can see my group, and who can join it?
5. What does my new group look like, and what is on its page?
6. How do I give it a picture, words and links?
6. How do I give it a picture and words?
7. What next: inviting people, writing rules.
## inviting-people.md
.claude/skills/ui/SKILL.md+2−2
@@ -43,10 +43,10 @@ picture, no words, no one else. That is the bare state. A seed puts in
the rest, once per kept world:
- `full`: Lantern Hikers (lanterns.groups.test), alice's, with a banner,
a picture, words, links, two rules and a moderator role; bob, carol
a picture, words, two rules and a moderator role; bob, carol
(moderator), dan, erin and frank in it, past a page of members; harbor
asking to join; an invite waiting for maximilianaquinces.
- `long`: a group of dan's with the longest handle, name, words, link
- `long`: a group of dan's with the longest handle, name, words, site
and rule the host takes; frank asking with a long note.
- `waiting`: bob asking to join Riders; carol invited to it.
- `apps`: an app signed in to Riders with alice's app password
crates/group-host/src/config.rs+0−6
@@ -44,10 +44,6 @@ pub struct Config {
/// `provisionGroup`, `PROVISIONING_CLIENTS`, comma-separated client
/// ids, `*` for any: none unless set.
pub provisioning_clients: Vec<String>,
/// Where a link's site's icon is asked when an MCP client writes a link
/// to a group's profile, `FAVICONS`: the link's address follows,
/// encoded. Bluesky's favicon service unless set; empty asks nowhere.
pub favicons: String,
/// Where a handle being typed is looked for, `ACTOR_SEARCH`: `plc`,
/// the handles in `PLC_URL`'s own export, or the URL of a service
/// answering `tech.waow.typeahead.searchActors`. The typeahead service
@@ -166,7 +162,6 @@ impl Config {
if reqwest::Url::parse(&console_url).is_err() {
bail!("CONSOLE_URL is no URL: {console_url}");
}
let favicons = var("FAVICONS").unwrap_or_else(|| group_host_mcp::FAVICONS.into());
let signup_pds = var("SIGNUP_PDS").unwrap_or_else(|| "https://bsky.social".into());
let signup_pds = signup_pds.trim_end_matches('/').to_string();
if reqwest::Url::parse(&signup_pds).is_err() {
@@ -203,7 +198,6 @@ impl Config {
blob_upload_limit,
console_url,
provisioning_clients,
favicons,
actor_search,
signup_pds,
host_admins,
crates/group-host/src/group_api.rs+1−11
@@ -119,17 +119,7 @@ fn cid_of(blob: &Value) -> Option<&str> {
/// Puts in `view` what a group's profile shows of it.
fn show_profile(view: &mut Value, profile: &Value) {
for key in [
"displayName",
"description",
"joinPolicy",
"url",
"links",
"location",
"online",
"topics",
"languages",
] {
for key in ["displayName", "description", "joinPolicy", "url"] {
if let Some(v) = profile.get(key) {
view[key] = v.clone();
}
crates/group-host/src/group_config.rs+16−92
@@ -23,17 +23,6 @@ type Answer = Result<Json<Value>, XrpcError>;
/// The most bytes a profile's picture may be, as its lexicon has it.
pub const IMAGE_AT_MOST: i64 = 2_000_000;
/// The most bytes a link's icon may be, as its lexicon has it.
pub const ICON_AT_MOST: i64 = 100_000;
/// Where a group meets: the places `community.lexicon.location` has.
const PLACES: [&str; 4] = [
"community.lexicon.location.address",
"community.lexicon.location.geo",
"community.lexicon.location.fsq",
"community.lexicon.location.hthree",
];
pub(crate) fn forbidden() -> XrpcError {
XrpcError::new(
StatusCode::FORBIDDEN,
@@ -111,106 +100,45 @@ fn said(text: &Value) -> bool {
text.as_str().is_some_and(|t| !t.trim().is_empty())
}
/// Refuses the words a profile lists at `key`, as `[{field}]`, if one is
/// blank or listed twice.
fn words(profile: &Value, key: &str, field: &str) -> Result<(), XrpcError> {
let mut seen: Vec<&str> = Vec::new();
for item in profile[key].as_array().into_iter().flatten() {
let word = item[field].as_str().unwrap_or_default().trim();
if word.is_empty() || seen.contains(&word) {
let once = format!("{key} lists each {field} once, and none blank");
return Err(invalid(once));
}
seen.push(word);
}
Ok(())
}
/// Refuses a place the profile says it meets that is none of [`PLACES`].
fn place(profile: &Value) -> Result<(), XrpcError> {
let Some(place) = profile.get("location") else {
return Ok(());
};
let kind = place["$type"].as_str().unwrap_or_default();
if !PLACES.contains(&kind) {
return Err(invalid(format!("location is one of {}", PLACES.join(", "))));
}
Ok(())
}
/// Whether `url` is an address on the web.
fn on_the_web(url: &Value) -> bool {
let url = url.as_str().unwrap_or_default();
url.starts_with("https://") || url.starts_with("http://")
}
/// Refuses a site, or a link, that is not on the web.
/// Refuses a site that is not on the web.
fn site(profile: &Value) -> Result<(), XrpcError> {
if profile.get("url").is_some_and(|url| !on_the_web(url)) {
let url = profile
.get("url")
.map(|url| url.as_str().unwrap_or_default());
if url.is_some_and(|url| !url.starts_with("https://") && !url.starts_with("http://")) {
return Err(invalid("url is an http or https address"));
}
let links = profile["links"].as_array().into_iter().flatten();
if links.into_iter().any(|link| !on_the_web(&link["url"])) {
return Err(invalid("each link's url is an http or https address"));
}
Ok(())
}
impl Host {
/// Refuses a picture a profile names at `key`, unless it is one of the
/// group's own uploads, of a kind of image a page is given and no
/// larger than a profile takes.
/// larger than a profile takes, with the type and size the host kept.
fn picture(&self, group: &str, profile: &Value, key: &str) -> Result<(), XrpcError> {
let Some(asked) = profile.get(key) else {
return Ok(());
};
let not_one = format!(
"{key} is a PNG, JPEG or WebP image of at most {IMAGE_AT_MOST} bytes, as the group's uploadBlob answered it"
);
self.image(group, asked, &PROFILE_IMAGES, IMAGE_AT_MOST, &not_one)
}
/// Refuses an icon a link names, unless it is one of the group's own
/// uploads, a PNG no larger than a link takes.
fn icons(&self, group: &str, profile: &Value) -> Result<(), XrpcError> {
let not_one = format!(
"a link's icon is a PNG image of at most {ICON_AT_MOST} bytes, as the group's uploadBlob answered it"
);
let links = profile["links"].as_array().into_iter().flatten();
for icon in links.filter_map(|link| link.get("icon")) {
self.image(group, icon, &["image/png"], ICON_AT_MOST, &not_one)?;
}
Ok(())
}
/// Refuses the blob `asked`, unless it is one of the group's own
/// uploads, of one of `kinds` and at most `at_most` bytes, with the
/// type and size the host kept: `not_one` says why.
fn image(
&self,
group: &str,
asked: &Value,
kinds: &[&str],
at_most: i64,
not_one: &str,
) -> Result<(), XrpcError> {
let not_one = || invalid(not_one.to_string());
let not_one = || {
invalid(format!(
"{key} is a PNG, JPEG or WebP image of at most {IMAGE_AT_MOST} bytes, as the group's uploadBlob answered it"
))
};
let link = asked["ref"]["$link"].as_str().unwrap_or_default();
let cid = Cid::parse(link).map_err(|_| not_one())?;
let kept = self.store.blob(group, &cid).map_err(XrpcError::internal)?;
let kept = kept.ok_or_else(not_one)?;
let image = kinds.contains(&kept.mime_type.as_str());
let image = PROFILE_IMAGES.contains(&kept.mime_type.as_str());
let as_kept = asked["mimeType"] == kept.mime_type && asked["size"] == kept.size;
if !image || kept.size > at_most || !as_kept {
if !image || kept.size > IMAGE_AT_MOST || !as_kept {
return Err(not_one());
}
Ok(())
}
/// Refuses a profile the group should not keep: one with no name, a
/// join policy the host does not know, a place that is none, a site or
/// link not on the web, words blank or listed twice, or a picture or a
/// link's icon that is not one of its own.
/// join policy the host does not know, a site not on the web, or a
/// picture that is not one of its own.
fn profile(&self, group: &str, profile: &Value) -> Result<(), XrpcError> {
if !said(&profile["displayName"]) {
return Err(invalid("displayName is required"));
@@ -218,13 +146,9 @@ impl Host {
if let Some(policy) = profile["joinPolicy"].as_str() {
join_policy(Some(policy))?;
}
place(profile)?;
site(profile)?;
words(profile, "topics", "topic")?;
words(profile, "languages", "language")?;
self.picture(group, profile, "avatar")?;
self.picture(group, profile, "banner")?;
self.icons(group, profile)
self.picture(group, profile, "banner")
}
/// Refuses a write of the group's profile or one of its rules, in its
crates/group-host/src/lexicons.rs+0−4
@@ -26,10 +26,6 @@ macro_rules! lexicon {
/// Every lexicon under `lexicons/`.
pub const FILES: &[&str] = &[
lexicon!("community/lexicon/location/address"),
lexicon!("community/lexicon/location/fsq"),
lexicon!("community/lexicon/location/geo"),
lexicon!("community/lexicon/location/hthree"),
lexicon!("fyi/opensocial/acceptance"),
lexicon!("fyi/opensocial/activateGroup"),
lexicon!("fyi/opensocial/addRecoveryKey"),
crates/group-host/src/mcp.rs+0−22
@@ -846,17 +846,6 @@ impl Host {
let kept = self.group_record(&who.group, &uri, &collection, &rkey);
let kept = kept.map_err(XrpcError::internal).map_err(said)?;
let kept = kept.unwrap_or_default();
// Each new link's site's icon, kept as the group's own.
let mut fields = fields;
let favicons = &self.config.favicons;
let wanted = group_host_mcp::iconless(&collection, &kept, &mut fields, favicons);
for (at, asked) in wanted {
let Some(png) = favicon(&self.http, &asked).await else {
continue;
};
let icon = self.upload_blob(&who.group, &png, "image/png");
group_host_mcp::iconed(&mut fields, at, icon.map_err(said)?);
}
let write = group_host_mcp::edited(&kept, space, collection, rkey, fields);
Box::pin(self.carry_out(who, write)).await
}
@@ -1035,14 +1024,3 @@ pub async fn revoke_connected_app(
ended.map_err(XrpcError::internal)?;
Ok(Json(json!({})))
}
/// The icon the favicon service answers at `asked`: a PNG no larger than
/// a link's icon may be, or none.
async fn favicon(http: &reqwest::Client, asked: &str) -> Option<Vec<u8>> {
let res = http.get(asked).send().await.ok()?;
let kind = res.headers().get(header::CONTENT_TYPE).cloned();
let png = res.status().is_success() && kind.is_some_and(|k| k == "image/png");
let bytes = res.bytes().await.ok()?;
let small = bytes.len() <= group_host_mcp::ICON_AT_MOST;
(png && small).then(|| bytes.to_vec())
}
crates/group-host/tests/common/mod.rs+0−29
@@ -212,35 +212,6 @@ async fn last(
.ok_or(StatusCode::NOT_FOUND)
}
/// The bytes the favicon service answers for a site whose name starts
/// `chat.`.
pub const FAVICON: &[u8] = b"\x89PNG a green dot";
/// A favicon service, as the host asks one: where it is, the link's
/// address to follow. A site whose name starts `chat.` has `FAVICON`, one
/// whose starts `big.` an icon larger than a link's may be, `gif.` one
/// that is no PNG; any other none.
pub async fn start_favicons() -> String {
async fn icon(
axum::extract::Query(q): axum::extract::Query<HashMap<String, String>>,
) -> axum::response::Response {
use axum::response::IntoResponse;
let site = q.get("url").map(String::as_str).unwrap_or_default();
let site = site.trim_start_matches("https://");
let png = [(axum::http::header::CONTENT_TYPE, "image/png")];
match site.split('.').next() {
Some("chat") => (png, FAVICON).into_response(),
Some("big") => (png, vec![0; 100_001]).into_response(),
Some("gif") => {
([(axum::http::header::CONTENT_TYPE, "image/gif")], "GIF89a").into_response()
}
_ => StatusCode::NOT_FOUND.into_response(),
}
}
let at = serve(Router::new().route("/favicon", get(icon))).await;
format!("{at}/favicon?url=")
}
/// Serves `router` on a free port, answering its address.
pub async fn serve(router: Router) -> String {
let listener = tokio::net::TcpListener::bind("127.0.0.1:0").await.unwrap();
crates/group-host/tests/group_config.rs+2−33
@@ -78,25 +78,11 @@ async fn an_admin_changes_the_profile() {
assert_eq!(avatar["size"], 2_000_000);
assert_eq!(avatar["mimeType"], "image/webp");
let banner = uploaded(&h, &app, &token, b"road".to_vec(), "image/jpeg").await;
// As large as a link's icon may be.
let icon = uploaded(&h, &app, &token, vec![8; 100_000], "image/png").await;
let record = riders(json!({
"displayName": "Riders United",
"description": "We ride.",
"url": "https://riders.example",
// As many links as a profile holds, a title as long as one may be.
"links": [
{"url": "https://chat.riders.example", "title": "Our chat", "icon": icon},
{"url": "http://calendar.riders.example/rides"},
{"url": "https://a.example", "title": "x".repeat(64)},
{"url": "https://b.example", "title": "B"},
{"url": "https://c.example", "title": "C"},
],
"joinPolicy": "invite",
"location": {"$type": "community.lexicon.location.address", "locality": "Ljubljana", "country": "SI"},
"online": true,
"topics": [{"topic": "bikes"}, {"topic": "x".repeat(64)}],
"languages": [{"language": "sl"}, {"language": "en-GB"}],
"avatar": avatar,
"banner": banner,
}));
@@ -118,7 +104,7 @@ async fn an_admin_changes_the_profile() {
let shown = view(&h, &did, Some(&alice)).await;
assert_eq!(shown["group"]["displayName"], "Riders United");
assert_eq!(shown["group"]["joinPolicy"], "invite");
assert_eq!(shown["group"]["links"], record["links"]);
assert_eq!(shown["group"]["url"], "https://riders.example");
// Replaced whole: what is left out goes, pictures and all.
let said = app
@@ -134,7 +120,7 @@ async fn an_admin_changes_the_profile() {
assert_eq!(said.status, 200, "{}", said.body);
let p = profile(&h, &did);
assert_eq!(p.get("avatar"), None);
assert_eq!(p.get("topics"), None);
assert_eq!(p.get("url"), None);
assert_eq!(p["joinPolicy"], "approval");
}
@@ -147,7 +133,6 @@ async fn refuses_a_profile_it_should_not_keep() {
let moving = uploaded(&h, &app, &token, b"GIF89a".to_vec(), "image/gif").await;
let large = uploaded(&h, &app, &token, vec![0; 2_000_001], "image/png").await;
let face = uploaded(&h, &app, &token, b"face".to_vec(), "image/webp").await;
let wide = uploaded(&h, &app, &token, vec![0; 100_001], "image/png").await;
// Its type and size are the upload's, whatever the record says.
let mut retyped = face.clone();
retyped["mimeType"] = json!("image/png");
@@ -160,17 +145,7 @@ async fn refuses_a_profile_it_should_not_keep() {
riders(json!({"joinPolicy": "sometimes"})),
// A join policy is one of the words the lexicon knows.
riders(json!({"joinPolicy": "fyi.opensocial.profile#invite"})),
riders(json!({"location": {"$type": "xyz.place"}})),
riders(json!({"url": "ftp://riders.example"})),
riders(
json!({"links": [{"url": "https://riders.example"}, {"url": "ftp://riders.example"}]}),
),
riders(json!({"links": [{"title": "Nowhere"}]})),
riders(json!({"links": [{"url": "https://riders.example", "title": "x".repeat(65)}]})),
riders(json!({"links": vec![json!({"url": "https://riders.example"}); 6]})),
riders(json!({"topics": [{"topic": "bikes"}, {"topic": " bikes "}]})),
riders(json!({"topics": [{"topic": " "}]})),
riders(json!({"languages": [{"language": "sl"}, {"language": "sl"}]})),
// Pictures that are not the group's own images, as it kept them.
riders(json!({"avatar": words})),
riders(json!({"avatar": moving})),
@@ -180,14 +155,8 @@ async fn refuses_a_profile_it_should_not_keep() {
riders(json!({"avatar": never})),
riders(json!({"avatar": anothers})),
riders(json!({"avatar": {"ref": "x"}})),
// Icons that are not the group's own small PNGs, as it kept them.
riders(json!({"links": [{"url": "https://riders.example", "icon": face}]})),
riders(json!({"links": [{"url": "https://riders.example", "icon": wide}]})),
riders(json!({"links": [{"url": "https://riders.example", "icon": anothers}]})),
// Longer than the lexicon has them, or not of its format.
riders(json!({"displayName": "x".repeat(65)})),
riders(json!({"topics": [{"topic": "x".repeat(65)}]})),
riders(json!({"languages": [{"language": "not a tag"}]})),
riders(json!({"description": "x".repeat(2001)})),
json!({"$type": format!("{NS}.profile"), "displayName": "Riders"}),
] {
crates/group-host/tests/groups.rs+2−2
@@ -123,7 +123,7 @@ async fn shows_a_group_as_each_viewer_may_see_it() {
Write::Update {
collection: format!("{NS}.profile"),
rkey: "self".into(),
value: json!({"$type": format!("{NS}.profile"), "displayName": "Riders", "joinPolicy": "open", "avatar": picture, "topics": [{"topic": "bikes"}]}),
value: json!({"$type": format!("{NS}.profile"), "displayName": "Riders", "joinPolicy": "open", "avatar": picture, "url": "https://riders.example"}),
},
rule_at("b", "Second", None, "2026-11-02T00:00:00Z"),
rule_at("a", "Third", None, "2026-11-03T00:00:00Z"),
@@ -141,7 +141,7 @@ async fn shows_a_group_as_each_viewer_may_see_it() {
assert_eq!(group["displayName"], "Riders");
assert_eq!(group["joinPolicy"], "open");
assert_eq!(group["avatar"], picture["ref"]["$link"]);
assert_eq!(group["topics"], json!([{"topic": "bikes"}]));
assert_eq!(group["url"], "https://riders.example");
let titles: Vec<&str> = group["rules"]
.as_array()
.unwrap()
crates/group-host/tests/mcp.rs+1−22
crates/group-host-mcp/src/lib.rs+6−120
crates/group-host-mcp/tests/protocol.rs+10−54
crates/opensocial/src/lib.rs+5−61
crates/opensocial/tests/commands.rs+6−46
docs/design/groups.md+4−13
docs/guides/shots/starting-bob-dark.png+0−0
A binary file, not shown.
docs/guides/shots/starting-bob.png+0−0
A binary file, not shown.
docs/guides/shots/starting-bob.txt+0−3
docs/guides/shots/starting-card-done-dark.png+0−0
A binary file, not shown.
docs/guides/shots/starting-card-done.png+0−0
A binary file, not shown.
docs/guides/shots/starting-card-done.txt+0−3
docs/guides/shots/starting-words-dark.png+0−0
A binary file, not shown.
docs/guides/shots/starting-words.png+0−0
A binary file, not shown.
docs/guides/shots/starting-words.txt+0−266
docs/guides/README.md+1−1
docs/guides/starting-a-group.md+7−29
docs/reference/cli.md+3−3
docs/reference/config.md+2−5
docs/reference/mcp.md+4−7
docs/development.md+4−4
examples/kicker/harness/world.mjs+3−31
harness/e2e/flows.spec.mjs+4−69
harness/look/seeds/full.mjs+3−31
harness/look/seeds/long.mjs+5−10
harness/lexicons.mjs+16−4
harness/world.mjs+3−31
lexicons/community/lexicon/location/address.jsondeleted+0−39
lexicons/community/lexicon/location/fsq.jsondeleted+0−27
lexicons/community/lexicon/location/geo.jsondeleted+0−26
lexicons/community/lexicon/location/hthree.jsondeleted+0−21
lexicons/fyi/opensocial/defs.json+0−129
lexicons/fyi/opensocial/profile.json+11−47
web/messages/en.json+0−34
web/src/lib/atoms/LinkIcon.sveltedeleted+0−15
web/src/lib/molecules/Facts.sveltedeleted+0−47
web/src/lib/molecules/Links.sveltedeleted+0−20
web/src/lib/molecules/PickMany.sveltedeleted+0−165
web/src/lib/organisms/GroupCard.svelte+3−18
web/src/lib/organisms/LinksEditor.sveltedeleted+0−63
web/src/lib/organisms/ProfileForm.svelte+3−73
web/src/lib/server/settings.ts+1−108
web/src/lib/images.ts+0−15
web/src/lib/places.tsdeleted+0−74
web/src/lib/saving.svelte.ts+2−4
web/src/routes/g/[handle]/settings/+page.svelte+1−14
web/src/routes/g/[handle]/+page.svelte+1−6
web/src/app.css+1−126
web/src/env.ts+0−5
AGENTS.md+2−2