fix: lang is not the default one anymore

This commit is contained in:
VC
2022-11-19 17:33:50 +01:00
parent a854243cf6
commit 032e3cf8dd

View File

@@ -19,14 +19,13 @@ mod state;
pub use state::{init_db, migrate_db};
use state::{read_state, write_state, TweetToToot};
use elefren::{prelude::*, status_builder::StatusBuilder};
use elefren::{prelude::*, status_builder::StatusBuilder, Language};
use futures::StreamExt;
use log::info;
use rusqlite::Connection;
use std::sync::Arc;
use tokio::{spawn, sync::Mutex};
use futures::StreamExt;
const DEFAULT_RATE_LIMIT: usize = 4;
const DEFAULT_PAGE_SIZE: i32 = 200;
@@ -57,7 +56,6 @@ pub async fn run(config: Config) {
spawn(async move {
info!("Starting treating {}", &mastodon_config.twitter_screen_name);
// retrieve the last tweet ID for the username
let lconn = task_conn.lock().await;
let last_tweet_id = read_state(&lconn, &mastodon_config.twitter_screen_name, None)?
@@ -78,6 +76,7 @@ pub async fn run(config: Config) {
for tweet in &feed {
info!("Treating Tweet {} inside feed", tweet.id);
let lconn = task_conn.lock().await;
// initiate the toot_reply_id var and retrieve the corresponding toot_id
let toot_reply_id: Option<String> = tweet.in_reply_to_user_id.and_then(|_| {
@@ -106,12 +105,20 @@ pub async fn run(config: Config) {
status_builder.status(&status_text).media_ids(status_medias);
// theard if necessary
if let Some(i) = toot_reply_id {
status_builder.in_reply_to(&i);
}
// language if any
if let Some(l) = &tweet.lang {
if let Some(r) = Language::from_639_1(l) {
status_builder.language(r);
}
}
// can be activated for test purposes
// status_builder.visibility(elefren::status_builder::Visibility::Private);
status_builder.visibility(elefren::status_builder::Visibility::Private);
let status = status_builder.build()?;