chadtmiller.com/group-host
atmosphere group host
0
0
A blob only a space holds is not served by the public repo's sync
crates/group-host/src/api.rs+8−3
| @@ -241,8 +241,9 @@ pub async fn resolve_handle( | ||
Ok(Json(json!({ "did": did.ok_or_else(not_found)? }))) | ||
} | ||
| ||
/// A blob a record of the account references, served as a download: a | ||
/// browser neither sniffs nor runs it. | ||
/// A blob a record in the account's public repo references, served as a | ||
/// download: a browser neither sniffs nor runs it. A blob only records in | ||
/// spaces hold is not the public repo's, and is fetched from its space. | ||
pub async fn get_blob( | ||
State(host): State<Arc<Host>>, | ||
Query(p): Query<Params>, | ||
| @@ -250,7 +251,11 @@ pub async fn get_blob( | ||
let did = did_of(&host, param(&p, "did")?)?; | ||
let cid = param(&p, "cid")?; | ||
let cid = atproto::Cid::parse(cid).map_err(|e| invalid(format!("cid: {e}")))?; | ||
let found = host.read_blob(&did, &cid).map_err(XrpcError::internal)?; | ||
let public = host.store.held_publicly(&did, &cid); | ||
let found = match public.map_err(XrpcError::internal)? { | ||
true => host.read_blob(&did, &cid).map_err(XrpcError::internal)?, | ||
false => None, | ||
}; | ||
let not_found = || { | ||
XrpcError::new( | ||
StatusCode::BAD_REQUEST, | ||
crates/group-host/tests/group_config.rs+18−1
| @@ -462,10 +462,27 @@ async fn shows_an_image_to_whoever_may_see_a_record_that_holds_it() { | ||
assert_eq!(image(&h, &did, &cid(&avatar), Some(&carol)).await.0, 404); | ||
assert_eq!(image(&h, &did, &cid(&avatar), Some(&bob)).await.0, 200); | ||
| ||
// In its public repo: anyone's. | ||
// Held only in a space, it is no blob of the public repo's: neither | ||
// fetched nor listed by its sync, which asks no one who they are. | ||
let synced = async |cid: String| { | ||
let query = format!("did={did}&cid={cid}"); | ||
h.get("com.atproto.sync.getBlob", &query).await | ||
}; | ||
let (status, said) = synced(cid(&avatar)).await; | ||
assert_eq!( | ||
(status, said["error"].as_str()), | ||
(400, Some("BlobNotFound")) | ||
); | ||
let (_, listed) = h | ||
.get("com.atproto.sync.listBlobs", &format!("did={did}")) | ||
.await; | ||
assert_eq!(listed["cids"], json!([])); | ||
| ||
// In its public repo: anyone's, there too. | ||
let photo = uploaded(&h, &app, &token, b"ride".to_vec(), "image/jpeg").await; | ||
h.host.write(&did, &[holding("ride", &photo)]).unwrap(); | ||
assert_eq!(image(&h, &did, &cid(&photo), None).await.0, 200); | ||
assert_eq!(synced(cid(&photo)).await.0, 200); | ||
| ||
// A file that is no image is not served as one, wherever it is held. | ||
let text = h.host.upload_blob(&did, b"words", "text/plain").unwrap(); | ||
docs/design/spaces.md+3−0
| @@ -67,6 +67,9 @@ Details: | ||
whose head moved under it fails rather than overwrite. | ||
- A blob belongs to the group and goes once no record in any of its repos | ||
references it. An upload no record takes within a day is swept. | ||
- A blob is read where a record holding it is: `com.atproto.sync.getBlob` | ||
and `listBlobs` answer only blobs the public repo holds, and a blob held | ||
only in a space is read through the space, by those who may read it. | ||
| ||
## Deciding who reads and writes | ||
| ||
docs/reference/api.md+1−1
| @@ -248,7 +248,7 @@ repos as any PDS does: | ||
| --- | --- | | ||
| `GET com.atproto.server.describeServer` | the host as a PDS: its DID, the domain it gives its groups names under, `BLOB_UPLOAD_LIMIT`, and that no one signs up | | ||
| `GET com.atproto.repo.describeRepo`, `GET com.atproto.repo.getRecord`, `GET com.atproto.repo.listRecords` | a group's public repo | | ||
| `GET com.atproto.sync.getRepo`, `GET com.atproto.sync.getLatestCommit`, `GET com.atproto.sync.listRepos`, `GET com.atproto.sync.getBlob`, `GET com.atproto.sync.listBlobs` | syncing them | | ||
| `GET com.atproto.sync.getRepo`, `GET com.atproto.sync.getLatestCommit`, `GET com.atproto.sync.listRepos`, `GET com.atproto.sync.getBlob`, `GET com.atproto.sync.listBlobs` | syncing them; a blob only a space holds is not served or listed | | ||
| `GET com.atproto.sync.subscribeRepos` | the firehose, over a WebSocket | | ||
| `GET com.atproto.identity.resolveHandle` | a handle here, to its DID; for a caller signed in, any handle, through `HANDLE_RESOLVERS` | | ||
| `GET /.well-known/did.json` | the host's own DID document, when `SERVICE_DID` is a `did:web`: its `#atproto_pds` and `#opensocial` services at `PUBLIC_URL` | | ||