|
|
|
@ -114,6 +114,7 @@ impl EmojiFetcher {
@@ -114,6 +114,7 @@ impl EmojiFetcher {
|
|
|
|
|
self.needs_interactive("logging into gotosocial", self.try_fetch_gts()) |
|
|
|
|
.await |
|
|
|
|
} |
|
|
|
|
FediSoftware::Akkoma => self.try_fetch_akkoma().await, |
|
|
|
|
FediSoftware::Other(other) => { |
|
|
|
|
error!("unsupported fedi software: `{other}`"); |
|
|
|
|
Ok(()) |
|
|
|
@ -166,11 +167,35 @@ impl EmojiFetcher {
@@ -166,11 +167,35 @@ impl EmojiFetcher {
|
|
|
|
|
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<()> { |
|
|
|
|
info!("Could not auto-detect which software the instance uses."); |
|
|
|
|
let options = vec![ |
|
|
|
|
FediSoftware::Mastodon, |
|
|
|
|
FediSoftware::Gotosocial, |
|
|
|
|
FediSoftware::Akkoma, |
|
|
|
|
FediSoftware::Other("".into()), |
|
|
|
|
]; |
|
|
|
|
let answer = inquire::Select::new("Please select the instance software:", options) |
|
|
|
|