mirror of
https://framagit.org/veretcle/scootaloo.git
synced 2025-07-20 17:11:19 +02:00
fix: lang is not the default one anymore
This commit is contained in:
17
src/lib.rs
17
src/lib.rs
@@ -19,14 +19,13 @@ mod state;
|
|||||||
pub use state::{init_db, migrate_db};
|
pub use state::{init_db, migrate_db};
|
||||||
use state::{read_state, write_state, TweetToToot};
|
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 log::info;
|
||||||
use rusqlite::Connection;
|
use rusqlite::Connection;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::{spawn, sync::Mutex};
|
use tokio::{spawn, sync::Mutex};
|
||||||
|
|
||||||
use futures::StreamExt;
|
|
||||||
|
|
||||||
const DEFAULT_RATE_LIMIT: usize = 4;
|
const DEFAULT_RATE_LIMIT: usize = 4;
|
||||||
const DEFAULT_PAGE_SIZE: i32 = 200;
|
const DEFAULT_PAGE_SIZE: i32 = 200;
|
||||||
|
|
||||||
@@ -57,7 +56,6 @@ pub async fn run(config: Config) {
|
|||||||
|
|
||||||
spawn(async move {
|
spawn(async move {
|
||||||
info!("Starting treating {}", &mastodon_config.twitter_screen_name);
|
info!("Starting treating {}", &mastodon_config.twitter_screen_name);
|
||||||
|
|
||||||
// retrieve the last tweet ID for the username
|
// retrieve the last tweet ID for the username
|
||||||
let lconn = task_conn.lock().await;
|
let lconn = task_conn.lock().await;
|
||||||
let last_tweet_id = read_state(&lconn, &mastodon_config.twitter_screen_name, None)?
|
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 {
|
for tweet in &feed {
|
||||||
info!("Treating Tweet {} inside feed", tweet.id);
|
info!("Treating Tweet {} inside feed", tweet.id);
|
||||||
|
|
||||||
let lconn = task_conn.lock().await;
|
let lconn = task_conn.lock().await;
|
||||||
// initiate the toot_reply_id var and retrieve the corresponding toot_id
|
// 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(|_| {
|
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);
|
status_builder.status(&status_text).media_ids(status_medias);
|
||||||
|
|
||||||
|
// theard if necessary
|
||||||
if let Some(i) = toot_reply_id {
|
if let Some(i) = toot_reply_id {
|
||||||
status_builder.in_reply_to(&i);
|
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
|
// 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()?;
|
let status = status_builder.build()?;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user