mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 09:44:46 +00:00
parent
85ef507ac7
commit
1e26709cb4
|
@ -39,6 +39,7 @@ pub struct GetPostResponse {
|
||||||
pub post_view: PostView,
|
pub post_view: PostView,
|
||||||
pub community_view: CommunityView,
|
pub community_view: CommunityView,
|
||||||
pub moderators: Vec<CommunityModeratorView>,
|
pub moderators: Vec<CommunityModeratorView>,
|
||||||
|
pub cross_posts: Vec<PostView>,
|
||||||
pub online: usize,
|
pub online: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ use lemmy_db_schema::{
|
||||||
source::{comment::Comment, local_site::LocalSite, post::Post},
|
source::{comment::Comment, local_site::LocalSite, post::Post},
|
||||||
traits::Crud,
|
traits::Crud,
|
||||||
};
|
};
|
||||||
use lemmy_db_views::structs::PostView;
|
use lemmy_db_views::{post_view::PostQuery, structs::PostView};
|
||||||
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
use lemmy_db_views_actor::structs::{CommunityModeratorView, CommunityView};
|
||||||
use lemmy_utils::{error::LemmyError, ConnectionId};
|
use lemmy_utils::{error::LemmyError, ConnectionId};
|
||||||
|
|
||||||
|
@ -96,6 +96,18 @@ impl PerformCrud for GetPost {
|
||||||
|
|
||||||
let moderators = CommunityModeratorView::for_community(context.pool(), community_id).await?;
|
let moderators = CommunityModeratorView::for_community(context.pool(), community_id).await?;
|
||||||
|
|
||||||
|
// Fetch the cross_posts
|
||||||
|
let cross_posts = if let Some(url) = &post_view.post.url {
|
||||||
|
PostQuery::builder()
|
||||||
|
.pool(context.pool())
|
||||||
|
.url_search(Some(url.inner().as_str().into()))
|
||||||
|
.build()
|
||||||
|
.list()
|
||||||
|
.await?
|
||||||
|
} else {
|
||||||
|
Vec::new()
|
||||||
|
};
|
||||||
|
|
||||||
let online = context
|
let online = context
|
||||||
.chat_server()
|
.chat_server()
|
||||||
.send(GetPostUsersOnline { post_id })
|
.send(GetPostUsersOnline { post_id })
|
||||||
|
@ -107,6 +119,7 @@ impl PerformCrud for GetPost {
|
||||||
community_view,
|
community_view,
|
||||||
moderators,
|
moderators,
|
||||||
online,
|
online,
|
||||||
|
cross_posts,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue