Remove Post.quote field and store linked posts in array
This commit is contained in:
parent
1bb876f8c5
commit
5862f49015
3 changed files with 11 additions and 11 deletions
|
@ -97,8 +97,8 @@ impl Status {
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let quote = post.quote.map(|quote| {
|
let quote = post.linked.get(0).map(|quote| {
|
||||||
let status = Status::from_post(*quote, instance_url);
|
let status = Status::from_post(quote.clone(), instance_url);
|
||||||
Box::new(status)
|
Box::new(status)
|
||||||
});
|
});
|
||||||
let visibility = match post.visibility {
|
let visibility = match post.visibility {
|
||||||
|
|
|
@ -25,15 +25,15 @@ pub async fn add_related_posts(
|
||||||
for post in posts {
|
for post in posts {
|
||||||
if let Some(ref repost_of_id) = post.repost_of_id {
|
if let Some(ref repost_of_id) = post.repost_of_id {
|
||||||
let mut repost_of = get_post(repost_of_id)?;
|
let mut repost_of = get_post(repost_of_id)?;
|
||||||
if let Some(quote_id) = repost_of.links.get(0) {
|
for linked_id in repost_of.links.iter() {
|
||||||
let quote = get_post(quote_id)?;
|
let linked = get_post(linked_id)?;
|
||||||
repost_of.quote = Some(Box::new(quote));
|
repost_of.linked.push(linked);
|
||||||
};
|
};
|
||||||
post.repost_of = Some(Box::new(repost_of));
|
post.repost_of = Some(Box::new(repost_of));
|
||||||
};
|
};
|
||||||
if let Some(quote_id) = post.links.get(0) {
|
for linked_id in post.links.iter() {
|
||||||
let quote = get_post(quote_id)?;
|
let linked = get_post(linked_id)?;
|
||||||
post.quote = Some(Box::new(quote));
|
post.linked.push(linked);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -107,7 +107,7 @@ pub struct Post {
|
||||||
pub actions: Option<PostActions>,
|
pub actions: Option<PostActions>,
|
||||||
pub in_reply_to: Option<Box<Post>>,
|
pub in_reply_to: Option<Box<Post>>,
|
||||||
pub repost_of: Option<Box<Post>>,
|
pub repost_of: Option<Box<Post>>,
|
||||||
pub quote: Option<Box<Post>>,
|
pub linked: Vec<Post>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Post {
|
impl Post {
|
||||||
|
@ -162,7 +162,7 @@ impl Post {
|
||||||
actions: None,
|
actions: None,
|
||||||
in_reply_to: None,
|
in_reply_to: None,
|
||||||
repost_of: None,
|
repost_of: None,
|
||||||
quote: None,
|
linked: vec![],
|
||||||
};
|
};
|
||||||
Ok(post)
|
Ok(post)
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ impl Default for Post {
|
||||||
actions: None,
|
actions: None,
|
||||||
in_reply_to: None,
|
in_reply_to: None,
|
||||||
repost_of: None,
|
repost_of: None,
|
||||||
quote: None,
|
linked: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue