add post, fix profile err

This commit is contained in:
2025-08-09 11:23:05 +09:00
parent 55745ff051
commit c3cb3db680
5 changed files with 1880 additions and 10 deletions

View File

@@ -45,7 +45,10 @@ pub struct ProfileFetcher {
impl ProfileFetcher {
pub fn new() -> Self {
Self {
client: reqwest::Client::new(),
client: reqwest::Client::builder()
.timeout(std::time::Duration::from_secs(30))
.build()
.unwrap_or_else(|_| reqwest::Client::new()),
}
}
@@ -84,11 +87,15 @@ impl ProfileFetcher {
let response = self.client
.get(&url)
.query(&[("repo", handle)])
.timeout(std::time::Duration::from_secs(10))
.send()
.await?;
.await
.map_err(|e| anyhow::anyhow!("Request failed: {}", e))?;
if !response.status().is_success() {
return Err(anyhow::anyhow!("Failed to describe repo: {}", response.status()));
let status = response.status();
let error_text = response.text().await.unwrap_or_default();
return Err(anyhow::anyhow!("Failed to describe repo: {} - {}", status, error_text));
}
let repo_desc: RepoDescription = response.json().await?;
@@ -117,11 +124,15 @@ impl ProfileFetcher {
let response = self.client
.get(&url)
.query(&[("actor", did)])
.timeout(std::time::Duration::from_secs(10))
.send()
.await?;
.await
.map_err(|e| anyhow::anyhow!("Request failed: {}", e))?;
if !response.status().is_success() {
return Err(anyhow::anyhow!("Failed to get profile: {}", response.status()));
let status = response.status();
let error_text = response.text().await.unwrap_or_default();
return Err(anyhow::anyhow!("Failed to get profile: {} - {}", status, error_text));
}
let profile_data: Value = response.json().await?;

View File

@@ -1875,7 +1875,7 @@ async fn check_and_process_new_posts(
async fn get_existing_records(config: &AuthConfig, collection: &str) -> Result<Vec<serde_json::Value>> {
let client = reqwest::Client::new();
let url = format!("{}/xrpc/com.atproto.repo.listRecords?repo={}&collection={}&limit=100",
let url = format!("{}/xrpc/com.atproto.repo.listRecords?repo={}&collection={}&limit=100&reverse=true",
config.admin.pds,
urlencoding::encode(&config.admin.did),
urlencoding::encode(collection));