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

grain.social/grain

photography-focused photo sharing platform

grain.social
1 collaborator
0
2

server: take atproto-client 0.11.1, and find an ended group session again

Merged chadtmiller.com asked to merge into main from grain.social/grain:deps/atproto-0.6
crates/grain-serve/src/groups/session.rs+13−4
@@ -15,6 +15,7 @@ use crate::index::Index;
use crate::login::store_error;
use anyhow::{Result, bail};
use atproto_client::oauth::{self, SessionStore, StoreError};
use atproto_client::space;
use grain::session::Session;
use std::sync::Arc;
@@ -32,11 +33,14 @@ impl std::fmt::Display for Ended {
impl std::error::Error for Ended {}
impl Ended {
/// Whether `e` is, or was caused by, a session ending: anywhere along
/// its chain, as inside a space read's failure to get a delegation
/// token (`space::Error::Delegation`).
/// Whether `e` is, or was caused by, a session ending: on its own, or
/// as a space read's failure to get a delegation token
/// (`space::Error::Delegation`).
pub fn of(e: &anyhow::Error) -> bool {
e.downcast_ref::<Ended>().is_some() || e.chain().any(|c| c.is::<Ended>())
let delegation = e
.downcast_ref::<space::Error>()
.and_then(space::Error::delegation);
e.is::<Ended>() || delegation.is_some_and(|d| d.is::<Ended>())
}
}
@@ -244,6 +248,11 @@ pub(crate) mod tests {
let e = anyhow::Error::from(Ended);
assert!(Ended::of(&e));
assert_eq!(e.to_string(), "the group's session with Grain has ended");
// Still known inside a space read that could get no token for it.
let read = space::Error::Delegation(Box::new(Ended));
assert!(Ended::of(&anyhow::Error::from(read).context("reading")));
let other = space::Error::Delegation("no route".into());
assert!(!Ended::of(&anyhow::Error::from(other)));
}
#[tokio::test]
crates/grain-serve/src/accounts.rs+8−14
@@ -301,13 +301,10 @@ pub async fn get_account_deletion_plan(
let most = crate::write::MOST_WRITES;
let mut writes: Vec<Value> = Vec::new();
'collections: for collection in collections(&pds, &did).await? {
let limit = (most - writes.len()).min(PAGE).to_string();
let params = [
("repo", did.as_str()),
("collection", collection.as_str()),
("limit", &limit),
];
let mut pages = pds.pages(LIST_RECORDS, &params, "records", None);
let limit = (most - writes.len()).min(PAGE) as u32;
let params = [("repo", did.as_str()), ("collection", collection.as_str())];
let pages = pds.pages(LIST_RECORDS, &params, "records", None);
let mut pages = pages.limit(limit);
while let Some(rkeys) = rkeys(&mut pages).await? {
let room = most - writes.len();
let rkeys = rkeys.into_iter().take(room);
@@ -331,13 +328,10 @@ async fn delete_some(app: &App, did: &str, budget: u64) -> Result<Step, Failure>
if step.deleted >= budget {
return Ok(step);
}
let limit = (budget - step.deleted).min(PAGE as u64).to_string();
let params = [
("repo", did),
("collection", collection.as_str()),
("limit", &limit),
];
let mut pages = pds.pages(LIST_RECORDS, &params, "records", None);
let limit = (budget - step.deleted).min(PAGE as u64) as u32;
let params = [("repo", did), ("collection", collection.as_str())];
let pages = pds.pages(LIST_RECORDS, &params, "records", None);
let mut pages = pages.limit(limit);
let rkeys = rkeys(&mut pages).await?.unwrap_or_default();
if rkeys.is_empty() {
break;
Cargo.lock+2−2
@@ -135,9 +135,9 @@ dependencies = [
[[package]]
name = "atproto-client"
version = "0.11.0"
version = "0.11.1"
source = "sparse+https://knotless.dev/cargo/did:plc:bcgltzqazw5tb6k2g3ttenbj/3mzr5vldibtui/"
checksum = "3c52aaf3b60a0e431c0d24b2a542854aaa1245af2794223ee1cd60a776a79cce"
checksum = "486b02a79ef4f41c99a67fb247bedbb4f6b82bfd0ee9f0f707c58ca082040a90"
dependencies = [
"atproto",
"bytes",
Cargo.toml+1−1
@@ -14,7 +14,7 @@ grain-serve = { path = "crates/grain-serve" }
# atproto's primitives, from their own repository's registry (.cargo/config.toml).
atproto = { version = "0.6.1", registry = "atproto" }
# atproto's client I/O, from the same registry.
atproto-client = { version = "0.11.0", registry = "atproto" }
atproto-client = { version = "0.11.1", registry = "atproto" }
# The server side of XRPC on axum, from the same registry.
atproto-server = { version = "0.3.0", registry = "atproto" }
aes-gcm = "0.10"