Allow forcing country for multiple profiles
In case it's necessary
This commit is contained in:
parent
883d02e328
commit
2fca5497e6
|
@ -10,9 +10,9 @@ use nederlandskie::services::{Bluesky, Database};
|
||||||
|
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Handle of the user to force the country for
|
/// Handles of the users to force the country for, comma-separated
|
||||||
#[arg(long)]
|
#[arg(long, required(true), value_delimiter(','))]
|
||||||
handle: String,
|
handle: Vec<String>,
|
||||||
|
|
||||||
/// Country to use, two letters
|
/// Country to use, two letters
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
|
@ -29,22 +29,23 @@ async fn main() -> Result<()> {
|
||||||
env::var("DATABASE_URL").context("DATABASE_URL environment variable must be set")?;
|
env::var("DATABASE_URL").context("DATABASE_URL environment variable must be set")?;
|
||||||
|
|
||||||
let bluesky = Bluesky::new("https://bsky.social");
|
let bluesky = Bluesky::new("https://bsky.social");
|
||||||
|
|
||||||
let did = bluesky
|
|
||||||
.resolve_handle(&args.handle)
|
|
||||||
.await?
|
|
||||||
.ok_or_else(|| anyhow!("No such user: {}", args.handle))?;
|
|
||||||
|
|
||||||
println!("Resolved handle '{}' to did '{}'", args.handle, did);
|
|
||||||
|
|
||||||
let database = Database::connect(&database_url).await?;
|
let database = Database::connect(&database_url).await?;
|
||||||
|
|
||||||
|
for handle in &args.handle {
|
||||||
|
let did = bluesky
|
||||||
|
.resolve_handle(handle)
|
||||||
|
.await?
|
||||||
|
.ok_or_else(|| anyhow!("No such user: {}", handle))?;
|
||||||
|
|
||||||
|
println!("Resolved handle '{}' to did '{}'", handle, did);
|
||||||
|
|
||||||
database.force_profile_country(&did, &args.country).await?;
|
database.force_profile_country(&did, &args.country).await?;
|
||||||
|
|
||||||
println!(
|
println!(
|
||||||
"Stored '{}' as the country for profile with did '{}'",
|
"Stored '{}' as the country for profile with did '{}'",
|
||||||
args.country, did
|
args.country, did
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue