mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
feat: add links in fields attribute
This commit is contained in:
@@ -268,7 +268,7 @@ pub async fn profile(config: Config, bot: Option<bool>) {
|
||||
&twitter_user.entities.description.urls,
|
||||
);
|
||||
|
||||
// let fields_attributes = get_attribute_from_url(&twitter_user.entities.url);
|
||||
let fields_attributes = get_attribute_from_url(&twitter_user.entities.url);
|
||||
|
||||
let display_name = Some(String::from_utf16_lossy(
|
||||
&twitter_user
|
||||
@@ -284,7 +284,6 @@ pub async fn profile(config: Config, bot: Option<bool>) {
|
||||
};
|
||||
|
||||
let update_creds = UpdateCredentialsInputOptions {
|
||||
discoverable: None,
|
||||
bot,
|
||||
display_name,
|
||||
note,
|
||||
@@ -293,9 +292,8 @@ pub async fn profile(config: Config, bot: Option<bool>) {
|
||||
.await?,
|
||||
),
|
||||
header,
|
||||
locked: None,
|
||||
source: None,
|
||||
fields_attributes: None,
|
||||
fields_attributes,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let mastodon = get_mastodon_token(&mastodon_config);
|
||||
|
@@ -63,7 +63,7 @@ fn main() {
|
||||
.short('c')
|
||||
.long("config")
|
||||
.value_name("CONFIG_FILE")
|
||||
.help(&format!(
|
||||
.help(format!(
|
||||
"TOML config file for scootaloo (default {})",
|
||||
DEFAULT_CONFIG_PATH
|
||||
))
|
||||
@@ -81,7 +81,7 @@ fn main() {
|
||||
.short('c')
|
||||
.long("config")
|
||||
.value_name("CONFIG_FILE")
|
||||
.help(&format!("TOML config file for scootaloo (default {})", DEFAULT_CONFIG_PATH))
|
||||
.help(format!("TOML config file for scootaloo (default {})", DEFAULT_CONFIG_PATH))
|
||||
.default_value(DEFAULT_CONFIG_PATH)
|
||||
.num_args(1)
|
||||
.display_order(1),
|
||||
@@ -104,7 +104,7 @@ fn main() {
|
||||
.short('c')
|
||||
.long("config")
|
||||
.value_name("CONFIG_FILE")
|
||||
.help(&format!("TOML config file for scootaloo (default {})", DEFAULT_CONFIG_PATH))
|
||||
.help(format!("TOML config file for scootaloo (default {})", DEFAULT_CONFIG_PATH))
|
||||
.default_value(DEFAULT_CONFIG_PATH)
|
||||
.num_args(1)
|
||||
.display_order(1),
|
||||
|
@@ -141,7 +141,6 @@ pub fn get_note_from_description(t: &Option<String>, urls: &[UrlEntity]) -> Opti
|
||||
}
|
||||
|
||||
/// Gets fields_attribute from UserEntityDetail
|
||||
#[allow(dead_code)]
|
||||
pub fn get_attribute_from_url(
|
||||
user_entity_detail: &Option<UserEntityDetail>,
|
||||
) -> Option<Vec<CredentialsFieldAttribute>> {
|
||||
|
13
src/util.rs
13
src/util.rs
@@ -4,7 +4,11 @@ use base64::encode;
|
||||
use egg_mode::tweet::Tweet;
|
||||
use futures::{stream, stream::StreamExt};
|
||||
use log::{error, info, warn};
|
||||
use megalodon::{mastodon::Mastodon, megalodon::Megalodon};
|
||||
use megalodon::{
|
||||
entities::UploadMedia::{AsyncAttachment, Attachment},
|
||||
mastodon::Mastodon,
|
||||
megalodon::Megalodon,
|
||||
};
|
||||
use reqwest::Url;
|
||||
use std::error::Error;
|
||||
use tokio::{
|
||||
@@ -49,7 +53,12 @@ pub async fn generate_media_ids(
|
||||
// it doesn’t matter if we can’t remove, cache_media fn is idempotent
|
||||
remove_file(&local_tweet_media_path).await.ok();
|
||||
|
||||
Ok::<String, ScootalooError>(mastodon_media.id)
|
||||
let id = match mastodon_media {
|
||||
Attachment(m) => m.id,
|
||||
AsyncAttachment(m) => m.id,
|
||||
};
|
||||
|
||||
Ok::<String, ScootalooError>(id)
|
||||
})
|
||||
})
|
||||
.buffered(4); // there are max four medias per tweet and they need to be treated in
|
||||
|
Reference in New Issue
Block a user