Our Personal Data Server from scratch!
0

Configure Feed

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

server: report absent repo rev instead of an empty one

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

author
Lewis
date (Jul 24, 2026, 8:45 PM +0300) commit e8371ff9 parent d57411ef change-id npsrrvpm
+22 -17
+22 -17
crates/tranquil-api/src/server/account_status.rs
··· 27 27 pub activated: bool, 28 28 pub valid_did: bool, 29 29 pub repo_commit: String, 30 - pub repo_rev: Tid, 30 + #[serde(serialize_with = "serialize_optional_rev")] 31 + pub repo_rev: Option<Tid>, 31 32 pub repo_blocks: i64, 32 33 pub indexed_records: i64, 33 34 pub private_state_values: i64, 34 35 pub expected_blobs: i64, 35 36 pub imported_blobs: i64, 37 + } 38 + 39 + fn serialize_optional_rev<S: serde::Serializer>( 40 + rev: &Option<Tid>, 41 + serializer: S, 42 + ) -> Result<S::Ok, S::Error> { 43 + serializer.serialize_str(rev.as_ref().map_or("", Tid::as_str)) 36 44 } 37 45 38 46 pub async fn check_account_status( ··· 65 73 .count_user_blocks(user_id) 66 74 .await 67 75 .unwrap_or(0); 68 - let repo_rev = if let Some(rev) = repo_rev_from_db { 69 - rev 70 - } else if !repo_commit.is_empty() { 71 - if let Ok(cid) = Cid::from_str(&repo_commit) { 72 - if let Ok(Some(block)) = state.block_store.get(&cid).await { 76 + let repo_rev = match (repo_rev_from_db, Cid::from_str(&repo_commit)) { 77 + (Some(rev), _) => Some(rev), 78 + (None, Ok(cid)) => state 79 + .block_store 80 + .get(&cid) 81 + .await 82 + .ok() 83 + .flatten() 84 + .and_then(|block| { 73 85 Commit::from_cbor(&block) 74 86 .ok() 75 - .map(|c| Tid::from(c.rev().to_string())) 76 - .unwrap_or_else(|| Tid::from(String::new())) 77 - } else { 78 - Tid::from(String::new()) 79 - } 80 - } else { 81 - Tid::from(String::new()) 82 - } 83 - } else { 84 - Tid::from(String::new()) 87 + .map(|commit| Tid::from(commit.rev().clone())) 88 + }), 89 + (None, Err(_)) => None, 85 90 }; 86 91 let record_count: i64 = state.repos.repo.count_records(user_id).await.unwrap_or(0); 87 92 let imported_blobs: i64 = state ··· 449 454 if let Ok(Some(block)) = state.block_store.get(&cid).await { 450 455 Commit::from_cbor(&block) 451 456 .ok() 452 - .map(|c| Tid::from(c.rev().to_string())) 457 + .map(|c| Tid::from(c.rev().clone())) 453 458 } else { 454 459 None 455 460 }