hunter/worker: learn hosts from reblogged accounts

This commit is contained in:
Astro 2023-03-09 00:58:30 +01:00
parent ec368e4557
commit fb21cf0335
2 changed files with 10 additions and 5 deletions

View File

@ -74,6 +74,8 @@ pub struct Post {
pub language: Option<String>,
#[serde(default)]
pub media_attachments: Vec<MediaAttachment>,
#[serde(default)]
pub reblog: Option<Box<Post>>,
}
impl Post {

View File

@ -192,6 +192,10 @@ async fn process_posts(
if ! posts_cache.insert(post.uri.clone()) {
let t1 = Instant::now();
// introduce instances from reblog authors
if let Some(reblog_account_host) = post.reblog.as_ref().and_then(|reblog| reblog.account.host()) {
introduce_hosts.insert(reblog_account_host);
}
// introduce instances from mentions
for mention in &post.mentions {
if let Some(user_host) = mention.user_host() {
@ -199,15 +203,14 @@ async fn process_posts(
}
}
// check if it's an actual post, not a repost
if let Some(author_host) = post.account.host() {
// check if it's an actual post
if let Some(account_host) = post.account.host() {
// send away to redis
if store.save_post(post).await == Ok(true) {
new_posts += 1;
}
// introduce instances from authors
introduce_hosts.insert(author_host);
// introduce instances from accounts
introduce_hosts.insert(account_host);
} else {
tracing::warn!("drop repost ({:?} on {})", post.account.host(), host);
}