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()
|
let reposted_ids: Vec<Uuid> = posts.iter()
|
||||||
.filter_map(|post| post.repost_of_id)
|
.filter_map(|post| post.repost_of_id)
|
||||||
.collect();
|
.collect();
|
||||||
let mut reposted = get_posts(db_client, reposted_ids).await?;
|
let reposted = get_posts(db_client, reposted_ids).await?;
|
||||||
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 index = reposted.iter()
|
let repost_of = reposted.iter()
|
||||||
.position(|post| post.id == *repost_of_id)
|
.find(|post| post.id == *repost_of_id)
|
||||||
.ok_or(DatabaseError::NotFound("post"))?;
|
.ok_or(DatabaseError::NotFound("post"))?
|
||||||
let repost_of = reposted.swap_remove(index);
|
.clone();
|
||||||
post.repost_of = Some(Box::new(repost_of));
|
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::models::profiles::types::DbActorProfile;
|
||||||
use crate::utils::html::clean_html;
|
use crate::utils::html::clean_html;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Visibility {
|
pub enum Visibility {
|
||||||
Public,
|
Public,
|
||||||
Direct,
|
Direct,
|
||||||
|
@ -67,11 +67,13 @@ pub struct DbPost {
|
||||||
}
|
}
|
||||||
|
|
||||||
// List of user's actions
|
// List of user's actions
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct PostActions {
|
pub struct PostActions {
|
||||||
pub favourited: bool,
|
pub favourited: bool,
|
||||||
pub reposted: bool,
|
pub reposted: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
pub struct Post {
|
pub struct Post {
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub author: DbActorProfile,
|
pub author: DbActorProfile,
|
||||||
|
|
Loading…
Reference in a new issue