Remove Post.quote field and store linked posts in array

This commit is contained in:
silverpill 2022-10-01 14:54:19 +00:00
parent 1bb876f8c5
commit 5862f49015
3 changed files with 11 additions and 11 deletions

View file

@ -97,8 +97,8 @@ impl Status {
} else {
None
};
let quote = post.quote.map(|quote| {
let status = Status::from_post(*quote, instance_url);
let quote = post.linked.get(0).map(|quote| {
let status = Status::from_post(quote.clone(), instance_url);
Box::new(status)
});
let visibility = match post.visibility {

View file

@ -25,15 +25,15 @@ pub async fn add_related_posts(
for post in posts {
if let Some(ref repost_of_id) = post.repost_of_id {
let mut repost_of = get_post(repost_of_id)?;
if let Some(quote_id) = repost_of.links.get(0) {
let quote = get_post(quote_id)?;
repost_of.quote = Some(Box::new(quote));
for linked_id in repost_of.links.iter() {
let linked = get_post(linked_id)?;
repost_of.linked.push(linked);
};
post.repost_of = Some(Box::new(repost_of));
};
if let Some(quote_id) = post.links.get(0) {
let quote = get_post(quote_id)?;
post.quote = Some(Box::new(quote));
for linked_id in post.links.iter() {
let linked = get_post(linked_id)?;
post.linked.push(linked);
};
};
Ok(())

View file

@ -107,7 +107,7 @@ pub struct Post {
pub actions: Option<PostActions>,
pub in_reply_to: Option<Box<Post>>,
pub repost_of: Option<Box<Post>>,
pub quote: Option<Box<Post>>,
pub linked: Vec<Post>,
}
impl Post {
@ -162,7 +162,7 @@ impl Post {
actions: None,
in_reply_to: None,
repost_of: None,
quote: None,
linked: vec![],
};
Ok(post)
}
@ -205,7 +205,7 @@ impl Default for Post {
actions: None,
in_reply_to: None,
repost_of: None,
quote: None,
linked: vec![],
}
}
}