···11use crate::jobs::account_backup::AccountBackupJobContext;
22use crate::jobs::{account_backup, pds_backup, push_job_json};
33use apalis::prelude::{Data, Error};
44+use jacquard::client::{AgentSessionExt, BasicClient};
55+use jacquard::url;
66+use jacquard_api::app_bsky::contact::match_and_contact_index_state::members::r#match;
77+use jacquard_api::com_atproto::sync::get_repo_status::{
88+ GetRepoStatus, GetRepoStatusError, GetRepoStatusOutput,
99+};
1010+use jacquard_common::CowStr;
1111+use jacquard_common::error::XrpcResult;
1212+use jacquard_common::xrpc::{XrpcClient, XrpcError};
1313+use lexicon_types_crate::com_pdsmoover::backup::get_repo_status::GetRepoStatusRequest;
414use serde::{Deserialize, Serialize};
515use sqlx::{Pool, Postgres};
616use std::sync::Arc;
···4050 .await
4151 .map_err(|e| Error::Failed(Arc::new(Box::new(e))))?;
42525353+ //TODO maybe check here?
5454+ let agent = BasicClient::unauthenticated();
4355 for (did, pds_host) in accounts {
5656+ //Need to do matches here cause I don't want to fail the whole loop
5757+ let pds_url = match url::Url::parse(&format!("https://{}", pds_host)) {
5858+ Ok(url) => url,
5959+ Err(e) => {
6060+ log::warn!("Failed to parse pds_host: {pds_host} \n {e}");
6161+ continue;
6262+ }
6363+ };
6464+6565+ //Sets the agent to the new PDS URL
6666+ agent.set_base_uri(pds_url).await;
6767+6868+ let request = GetRepoStatus {
6969+ //May just leave this ?
7070+ did: did.clone().parse().map_err(|_| {
7171+ Error::Failed(Arc::new(Box::new(std::io::Error::new(
7272+ std::io::ErrorKind::Other,
7373+ "Failed to parse did",
7474+ ))))
7575+ })?,
7676+ };
7777+7878+ let rev = match agent.send(request).await {
7979+ Ok(response) => match response.parse() {
8080+ Ok(output) => {
8181+ if output.active {
8282+ output.rev;
8383+ }
8484+ match output.status {
8585+ None => {
8686+ log::warn!(
8787+ "{did} has no status and not active. Not sure if this happens"
8888+ );
8989+ continue;
9090+ }
9191+ Some(status) => {
9292+ if status == "deactivated" {
9393+ //TODO do that call to update the PDS for the user
9494+ } else {
9595+ log::warn!("{did} has the repo status {status}.");
9696+ continue;
9797+ }
9898+ }
9999+ }
100100+ }
101101+ Err(err) => {
102102+ log::warn!("Failed to parse GetRepoStatusResponse for: {did} \n {err}");
103103+ continue;
104104+ }
105105+ },
106106+ Err(err) => {
107107+ log::warn!("Failed to send GetRepoStatusRequest for: {did} \n {err}");
108108+ continue;
109109+ }
110110+ };
111111+112112+ let rev_string: Option<String> = rev.map(|r| r.to_string());
113113+44114 let ctx = AccountBackupJobContext {
45115 did,
46116 pds_host,
4747- rev: None,
117117+ rev: rev_string,
48118 };
119119+49120 push_job_json(&pool, account_backup::JOB_NAMESPACE, &ctx).await?;
50121 }
51122
+1
shared/src/jobs/upload_blob.rs
···6767 BlobType::Repo(rev) => {
6868 let current_rev = match rev {
6969 None => {
7070+ //todo Prob just always pass in a rev? induivial uplaods do this anyhow
7071 let url = format!(
7172 "https://{}/xrpc/com.atproto.sync.getRepoStatus?did={}",
7273 pds_host, did,