X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapi_common%2Fsrc%2Fbuild_response.rs;h=a61da7f0b7627a2ce3fcc6b5e547aae78d2cc9f9;hb=5d23ef960e3361d1cc38c1aff1d907d8da58b90f;hp=8b96206cb214a1489fa5e690f98ea365cf6dfaae;hpb=1d38aad9d3d51ef606074d5b49a8030c49dd0e9e;p=lemmy.git diff --git a/crates/api_common/src/build_response.rs b/crates/api_common/src/build_response.rs index 8b96206c..a61da7f0 100644 --- a/crates/api_common/src/build_response.rs +++ b/crates/api_common/src/build_response.rs @@ -64,7 +64,7 @@ pub async fn build_community_response( } pub async fn build_post_response( - context: &Data, + context: &LemmyContext, community_id: CommunityId, person_id: PersonId, post_id: PostId, @@ -82,6 +82,19 @@ pub async fn build_post_response( Ok(PostResponse { post_view }) } +// this is a variation of build_post_response that returns post even if end-user-delted or mod-removed. +// Assumption is that before this function is ever called, the user is already confirmed to be authorized to view post. +// See GitHub Issue #3588 +pub async fn build_post_response_deleted_allowed( + context: &Data, + _community_id: CommunityId, + person_id: PersonId, + post_id: PostId, +) -> Result { + let post_view = PostView::read(&mut context.pool(), post_id, Some(person_id), Some(true)).await?; + Ok(PostResponse { post_view }) +} + // TODO: this function is a mess and should be split up to handle email seperately #[tracing::instrument(skip_all)] pub async fn send_local_notifs(