Our Personal Data Server from scratch!
0

Configure Feed

Select the types of activity you want to include in your feed.

sync: parse xrpc query params into real types

Lewis: May this revision serve well! <lu5a@proton.me>

author
Lewis
date (Jul 24, 2026, 8:45 PM +0300) commit d57411ef parent 84df045c change-id pupwvzkz
+12 -10
+6 -5
crates/tranquil-sync/src/blob.rs
··· 1 1 use axum::{ 2 2 Json, 3 3 body::Body, 4 - extract::{Query, State}, 4 + extract::State, 5 5 http::StatusCode, 6 6 http::header, 7 7 response::{IntoResponse, Response}, ··· 9 9 use serde::{Deserialize, Serialize}; 10 10 use tracing::error; 11 11 use tranquil_pds::api::error::ApiError; 12 + use tranquil_pds::api::query::XrpcQuery; 12 13 use tranquil_pds::state::AppState; 13 14 use tranquil_pds::sync::util::{RepoAccessLevel, assert_repo_availability}; 14 15 use tranquil_types::{CidLink, Did, Tid}; ··· 21 22 22 23 pub async fn get_blob( 23 24 State(state): State<AppState>, 24 - Query(params): Query<GetBlobParams>, 25 + XrpcQuery(params): XrpcQuery<GetBlobParams>, 25 26 ) -> Response { 26 27 let did = params.did; 27 28 let cid = params.cid; ··· 61 62 #[derive(Deserialize)] 62 63 pub struct ListBlobsParams { 63 64 pub did: Did, 64 - pub since: Option<String>, 65 + pub since: Option<Tid>, 65 66 pub limit: Option<i64>, 66 67 pub cursor: Option<String>, 67 68 } ··· 75 76 76 77 pub async fn list_blobs( 77 78 State(state): State<AppState>, 78 - Query(params): Query<ListBlobsParams>, 79 + XrpcQuery(params): XrpcQuery<ListBlobsParams>, 79 80 ) -> Response { 80 81 let did = params.did; 81 82 ··· 95 96 state 96 97 .repos 97 98 .blob 98 - .list_blobs_since_rev(&did, &Tid::from(since.clone())) 99 + .list_blobs_since_rev(&did, since) 99 100 .await 100 101 .map(|cids| { 101 102 let mut cids = cids;
+6 -5
crates/tranquil-sync/src/commit.rs
··· 1 1 use axum::{ 2 2 Json, 3 - extract::{Query, State}, 3 + extract::State, 4 4 http::StatusCode, 5 5 response::{IntoResponse, Response}, 6 6 }; ··· 12 12 use tracing::error; 13 13 use tranquil_db_traits::AccountStatus; 14 14 use tranquil_pds::api::error::ApiError; 15 + use tranquil_pds::api::query::XrpcQuery; 15 16 use tranquil_pds::state::AppState; 16 17 use tranquil_pds::sync::util::{ 17 18 RepoAccessLevel, assert_repo_availability, get_account_with_status, ··· 22 23 let cid = Cid::from_str(cid_str).ok()?; 23 24 let block = state.block_store.get(&cid).await.ok()??; 24 25 let commit = Commit::from_cbor(&block).ok()?; 25 - Some(Tid::from(commit.rev().to_string())) 26 + Some(Tid::from(commit.rev().clone())) 26 27 } 27 28 28 29 #[derive(Deserialize)] ··· 38 39 39 40 pub async fn get_latest_commit( 40 41 State(state): State<AppState>, 41 - Query(params): Query<GetLatestCommitParams>, 42 + XrpcQuery(params): XrpcQuery<GetLatestCommitParams>, 42 43 ) -> Response { 43 44 let did = params.did; 44 45 ··· 98 99 99 100 pub async fn list_repos( 100 101 State(state): State<AppState>, 101 - Query(params): Query<ListReposParams>, 102 + XrpcQuery(params): XrpcQuery<ListReposParams>, 102 103 ) -> Response { 103 104 let limit = params.limit.unwrap_or(50).clamp(1, 1000); 104 105 let cursor_did: Option<Did> = params.cursor.as_ref().and_then(|s| s.parse().ok()); ··· 173 174 174 175 pub async fn get_repo_status( 175 176 State(state): State<AppState>, 176 - Query(params): Query<GetRepoStatusParams>, 177 + XrpcQuery(params): XrpcQuery<GetRepoStatusParams>, 177 178 ) -> Response { 178 179 let did = params.did; 179 180