Allow timeline to contain multiple reposts of a post
This commit is contained in:
parent
82fe25d458
commit
3be313a0bf
2 changed files with 8 additions and 6 deletions
|
@ -14,13 +14,13 @@ pub async fn get_reposted_posts(
|
|||
let reposted_ids: Vec<Uuid> = posts.iter()
|
||||
.filter_map(|post| post.repost_of_id)
|
||||
.collect();
|
||||
let mut reposted = get_posts(db_client, reposted_ids).await?;
|
||||
let reposted = get_posts(db_client, reposted_ids).await?;
|
||||
for post in posts {
|
||||
if let Some(ref repost_of_id) = post.repost_of_id {
|
||||
let index = reposted.iter()
|
||||
.position(|post| post.id == *repost_of_id)
|
||||
.ok_or(DatabaseError::NotFound("post"))?;
|
||||
let repost_of = reposted.swap_remove(index);
|
||||
let repost_of = reposted.iter()
|
||||
.find(|post| post.id == *repost_of_id)
|
||||
.ok_or(DatabaseError::NotFound("post"))?
|
||||
.clone();
|
||||
post.repost_of = Some(Box::new(repost_of));
|
||||
};
|
||||
};
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::models::attachments::types::DbMediaAttachment;
|
|||
use crate::models::profiles::types::DbActorProfile;
|
||||
use crate::utils::html::clean_html;
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Visibility {
|
||||
Public,
|
||||
Direct,
|
||||
|
@ -67,11 +67,13 @@ pub struct DbPost {
|
|||
}
|
||||
|
||||
// List of user's actions
|
||||
#[derive(Clone)]
|
||||
pub struct PostActions {
|
||||
pub favourited: bool,
|
||||
pub reposted: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Post {
|
||||
pub id: Uuid,
|
||||
pub author: DbActorProfile,
|
||||
|
|
Loading…
Reference in a new issue