Skip to content

Commit

Permalink
feat(sync): decide on mastodon visibility if toot is synced
Browse files Browse the repository at this point in the history
  • Loading branch information
9Lukas5 committed Apr 16, 2023
1 parent 893b191 commit 0564954
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 7 additions & 0 deletions src/thread_replies.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0564954

Please sign in to comment.