From 0564954b69358c5aa367a9e8c95944b862b3c2dd Mon Sep 17 00:00:00 2001 From: 9Lukas5 Date: Sun, 16 Apr 2023 14:34:56 +0200 Subject: [PATCH] feat(sync): decide on mastodon visibility if toot is synced --- src/sync.rs | 9 ++++++--- src/thread_replies.rs | 7 +++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/sync.rs b/src/sync.rs index 1b2aedf..a7b1451 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -6,6 +6,7 @@ use elefren::entities::status::Status; use regex::Regex; use std::collections::HashSet; use std::fs; +use elefren::status_builder::Visibility; use unicode_segmentation::UnicodeSegmentation; // Represents new status updates that should be posted to Twitter (tweets) and @@ -134,9 +135,11 @@ pub fn determine_posts( None => tweet_shorten(&fulltext, &toot.url), Some(reblog) => tweet_shorten(&fulltext, &reblog.url), }; - // Skip direct toots to other Mastodon users, even if they are public. - if post.starts_with('@') { - continue; + + // ignore toots that are not public or unlisted + match toot.visibility { + Visibility::Public | Visibility::Unlisted => (), + _ => continue, } for tweet in twitter_statuses { diff --git a/src/thread_replies.rs b/src/thread_replies.rs index c3529f5..76e7b48 100644 --- a/src/thread_replies.rs +++ b/src/thread_replies.rs @@ -1,6 +1,7 @@ use crate::sync::*; use egg_mode::tweet::Tweet; use elefren::entities::status::Status; +use elefren::status_builder::Visibility; // A reply to a post that has the ID to the parent post. #[derive(Debug)] @@ -82,6 +83,12 @@ pub fn determine_thread_replies( continue; } + // ignore toots that are not public or unlisted + match toot.visibility { + Visibility::Public | Visibility::Unlisted => (), + _ => continue, + } + for tweet in twitter_statuses { // If the toot already exists we can stop here and know that we are // synced.