···
agent::atp_agent::{store::MemorySessionStore, AtpAgent},
3
-
com::atproto::server::{create_account, get_service_auth},
3
+
app::bsky::actor::{get_preferences, put_preferences},
5
+
server::{create_account, get_service_auth},
6
+
sync::{get_blob, get_repo, list_blobs},
types::string::{Handle, Nsid},
use atrium_xrpc_client::reqwest::ReqwestClient;
···
61
-
println!("First migration step is registering an account with your new PDS");
let new_pds_url = match readln(Some(
"Please type in the URL of the PDS you want to migrate to: ",
···
74
+
println!("Creating an account on your new PDS ...");
let new_agent = AtpAgent::new(
ReqwestClient::new(&new_pds_url),
MemorySessionStore::default(),
···
186
+
println!("com.atproto.server.createAccount at new PDS failed due to error: {err}");
190
+
println!("Successfully created account on your new PDS!");
194
+
println!("Migrating your data");
196
+
let car = match old_agent
202
+
get_repo::ParametersData {
203
+
did: old_agent.did().await.unwrap(),
Ok(response) => response,
182
-
println!("com.atproto.server.createAccount at new PDS failed due to error: {err}");
212
+
println!("com.atproto.sync.getRepo at current PDS failed due to error: {err}");
217
+
match new_agent.api.com.atproto.repo.import_repo(car).await {
220
+
println!("com.atproto.repo.importRepo at new PDS failed due to error: {err}");
224
+
println!("Repository successfully migrated");
226
+
let mut listed_blobs = match old_agent
232
+
list_blobs::ParametersData {
234
+
did: old_agent.did().await.unwrap(),
242
+
Ok(response) => response,
244
+
println!("com.atproto.sync.listBlobs at old PDS failed due to error: {err}");
249
+
while listed_blobs.cursor.is_some() {
250
+
for cid in listed_blobs.cids.iter() {
251
+
let blob = match old_agent
257
+
get_blob::ParametersData {
258
+
cid: cid.to_owned(),
259
+
did: old_agent.did().await.unwrap(),
265
+
Ok(response) => response,
267
+
println!("com.atproto.sync.getBlob at current PDS failed due to error: {err}");
272
+
match new_agent.api.com.atproto.repo.upload_blob(blob).await {
275
+
println!("com.atproto.repo.uploadBlob at new PDS failed due to error: {err}");
281
+
listed_blobs = match old_agent
287
+
list_blobs::ParametersData {
288
+
cursor: listed_blobs.cursor.clone(),
289
+
did: old_agent.did().await.unwrap(),
297
+
Ok(response) => response,
299
+
println!("com.atproto.sync.listBlobs at old PDS failed due to error: {err}");
304
+
println!("Blobs successfully migrated!");
306
+
let prefs = match old_agent
311
+
.get_preferences(get_preferences::ParametersData {}.into())
314
+
Ok(response) => response,
316
+
println!("app.bsky.actor.getPreferences at current PDS failed due to error: {err}");
327
+
put_preferences::InputData {
328
+
preferences: prefs.preferences.clone(),
336
+
println!("app.bsky.actor.putPreferences at new PDS failed due to error: {err}");
340
+
println!("Preferences successfully migrated!");