Add a way to force profile country by DID
This is useful to fixup broken profiles. Ideally, of course, we should be retrying a few times and then giving up, but that seems kinda too much for a little hobby project. Also, metrics would be nice, but, you know
This commit is contained in:
parent
85efe62fdf
commit
3f979af5d8
|
@ -2,7 +2,7 @@ extern crate nederlandskie;
|
||||||
|
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use anyhow::{anyhow, Context, Result};
|
use anyhow::{anyhow, bail, Context, Result};
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
|
|
||||||
|
@ -11,9 +11,13 @@ use nederlandskie::services::{Bluesky, Database};
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
struct Args {
|
struct Args {
|
||||||
/// Handles of the users to force the country for, comma-separated
|
/// Handles of the users to force the country for, comma-separated
|
||||||
#[arg(long, required(true), value_delimiter(','))]
|
#[arg(long, value_delimiter(','))]
|
||||||
handle: Vec<String>,
|
handle: Vec<String>,
|
||||||
|
|
||||||
|
/// DIDs of the users to force the country for, comma-separated
|
||||||
|
#[arg(long, value_delimiter(','))]
|
||||||
|
did: Vec<String>,
|
||||||
|
|
||||||
/// Country to use, two letters
|
/// Country to use, two letters
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
country: String,
|
country: String,
|
||||||
|
@ -25,6 +29,10 @@ async fn main() -> Result<()> {
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
|
if args.handle.is_empty() && args.did.is_empty() {
|
||||||
|
bail!("Either --handle or --did must be supplied");
|
||||||
|
}
|
||||||
|
|
||||||
let database_url =
|
let database_url =
|
||||||
env::var("DATABASE_URL").context("DATABASE_URL environment variable must be set")?;
|
env::var("DATABASE_URL").context("DATABASE_URL environment variable must be set")?;
|
||||||
|
|
||||||
|
@ -47,5 +55,14 @@ async fn main() -> Result<()> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for did in &args.did {
|
||||||
|
database.force_profile_country(&did, &args.country).await?;
|
||||||
|
|
||||||
|
println!(
|
||||||
|
"Stored '{}' as the country for profile with did '{}'",
|
||||||
|
args.country, did
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue