hunter/worker: learn hosts from reblogged accounts
This commit is contained in:
parent
ec368e4557
commit
fb21cf0335
|
@ -74,6 +74,8 @@ pub struct Post {
|
||||||
pub language: Option<String>,
|
pub language: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub media_attachments: Vec<MediaAttachment>,
|
pub media_attachments: Vec<MediaAttachment>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub reblog: Option<Box<Post>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Post {
|
impl Post {
|
||||||
|
|
|
@ -192,6 +192,10 @@ async fn process_posts(
|
||||||
if ! posts_cache.insert(post.uri.clone()) {
|
if ! posts_cache.insert(post.uri.clone()) {
|
||||||
let t1 = Instant::now();
|
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
|
// introduce instances from mentions
|
||||||
for mention in &post.mentions {
|
for mention in &post.mentions {
|
||||||
if let Some(user_host) = mention.user_host() {
|
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
|
// check if it's an actual post
|
||||||
if let Some(author_host) = post.account.host() {
|
if let Some(account_host) = post.account.host() {
|
||||||
// send away to redis
|
// send away to redis
|
||||||
if store.save_post(post).await == Ok(true) {
|
if store.save_post(post).await == Ok(true) {
|
||||||
new_posts += 1;
|
new_posts += 1;
|
||||||
}
|
}
|
||||||
|
// introduce instances from accounts
|
||||||
// introduce instances from authors
|
introduce_hosts.insert(account_host);
|
||||||
introduce_hosts.insert(author_host);
|
|
||||||
} else {
|
} else {
|
||||||
tracing::warn!("drop repost ({:?} on {})", post.account.host(), host);
|
tracing::warn!("drop repost ({:?} on {})", post.account.host(), host);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue