Compare commits

..

No commits in common. '1f89393c73271d33a91c2ab8f243ed02d4d68b03' and 'dc3d5df207f45a012cfedd10f6c03dd409ec723a' have entirely different histories.

  1. 2
      Cargo.lock
  2. 2
      Cargo.toml
  3. 25
      src/fetcher.rs
  4. 3
      src/misc.rs

2
Cargo.lock generated

@ -322,7 +322,7 @@ dependencies = [
[[package]] [[package]]
name = "fedi_emoji_downloader" name = "fedi_emoji_downloader"
version = "0.1.3" version = "0.1.2"
dependencies = [ dependencies = [
"chrono", "chrono",
"clap", "clap",

2
Cargo.toml

@ -1,6 +1,6 @@
[package] [package]
name = "fedi_emoji_downloader" name = "fedi_emoji_downloader"
version = "0.1.3" version = "0.1.2"
edition = "2021" edition = "2021"
[dependencies] [dependencies]

25
src/fetcher.rs

@ -114,7 +114,6 @@ impl EmojiFetcher {
self.needs_interactive("logging into gotosocial", self.try_fetch_gts()) self.needs_interactive("logging into gotosocial", self.try_fetch_gts())
.await .await
} }
FediSoftware::Akkoma => self.try_fetch_akkoma().await,
FediSoftware::Other(other) => { FediSoftware::Other(other) => {
error!("unsupported fedi software: `{other}`"); error!("unsupported fedi software: `{other}`");
Ok(()) Ok(())
@ -167,35 +166,11 @@ impl EmojiFetcher {
Ok(()) Ok(())
} }
async fn try_fetch_akkoma(&self) -> Result<()> {
info!("trying to fetch emojis from akkoma");
info!("trying without authentication");
let unauth_res = self.do_fetch(|rb| rb).await;
if unauth_res.is_ok() {
info!("successfully fetched from akkoma without authentication");
return Ok(());
}
info!("seems like authentication is needed; asking necessary info");
let access_token = self
.needs_interactive(
"logging into akkoma",
mastodon::auth_interactive(&self.client),
)
.await?;
mastodon::verify_login(&self.client, &access_token).await?;
self.do_fetch(|rb| rb.bearer_auth(&access_token)).await?;
mastodon::invalidate_token(&self.client, &access_token).await
}
async fn ask_target_and_try_fetch(&self) -> Result<()> { async fn ask_target_and_try_fetch(&self) -> Result<()> {
info!("Could not auto-detect which software the instance uses."); info!("Could not auto-detect which software the instance uses.");
let options = vec![ let options = vec![
FediSoftware::Mastodon, FediSoftware::Mastodon,
FediSoftware::Gotosocial, FediSoftware::Gotosocial,
FediSoftware::Akkoma,
FediSoftware::Other("".into()), FediSoftware::Other("".into()),
]; ];
let answer = inquire::Select::new("Please select the instance software:", options) let answer = inquire::Select::new("Please select the instance software:", options)

3
src/misc.rs

@ -7,7 +7,6 @@ use serde::Deserialize;
pub enum FediSoftware { pub enum FediSoftware {
Mastodon, Mastodon,
Gotosocial, Gotosocial,
Akkoma,
Other(String), Other(String),
#[default] #[default]
Unknown, Unknown,
@ -21,7 +20,6 @@ where
match value.as_ref() { match value.as_ref() {
"mastodon" => FediSoftware::Mastodon, "mastodon" => FediSoftware::Mastodon,
"gotosocial" => FediSoftware::Gotosocial, "gotosocial" => FediSoftware::Gotosocial,
"akkoma" => FediSoftware::Akkoma,
"" => FediSoftware::Unknown, "" => FediSoftware::Unknown,
other => FediSoftware::Other(other.to_owned()), other => FediSoftware::Other(other.to_owned()),
} }
@ -33,7 +31,6 @@ impl Display for FediSoftware {
match self { match self {
FediSoftware::Mastodon => write!(f, "Mastodon"), FediSoftware::Mastodon => write!(f, "Mastodon"),
FediSoftware::Gotosocial => write!(f, "Gotosocial"), FediSoftware::Gotosocial => write!(f, "Gotosocial"),
FediSoftware::Akkoma => write!(f, "Akkoma"),
FediSoftware::Other(_) => write!(f, "Other Software"), FediSoftware::Other(_) => write!(f, "Other Software"),
FediSoftware::Unknown => write!(f, "Unknown Software"), FediSoftware::Unknown => write!(f, "Unknown Software"),
} }

Loading…
Cancel
Save