mirror of https://github.com/LemmyNet/lemmy.git
Addressing PR comments.
parent
ac55f60c41
commit
9b42820479
|
@ -72,11 +72,5 @@ pub async fn feature_post(
|
|||
)
|
||||
.await?;
|
||||
|
||||
build_post_response(
|
||||
&context,
|
||||
orig_post.community_id,
|
||||
&local_user_view.person,
|
||||
post_id,
|
||||
)
|
||||
.await
|
||||
build_post_response(&context, orig_post.community_id, local_user_view, post_id).await
|
||||
}
|
||||
|
|
|
@ -85,11 +85,5 @@ pub async fn like_post(
|
|||
)
|
||||
.await?;
|
||||
|
||||
build_post_response(
|
||||
context.deref(),
|
||||
post.community_id,
|
||||
&local_user_view.person,
|
||||
post_id,
|
||||
)
|
||||
.await
|
||||
build_post_response(context.deref(), post.community_id, local_user_view, post_id).await
|
||||
}
|
||||
|
|
|
@ -63,11 +63,5 @@ pub async fn lock_post(
|
|||
)
|
||||
.await?;
|
||||
|
||||
build_post_response(
|
||||
&context,
|
||||
orig_post.community_id,
|
||||
&local_user_view.person,
|
||||
post_id,
|
||||
)
|
||||
.await
|
||||
build_post_response(&context, orig_post.community_id, local_user_view, post_id).await
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ use lemmy_db_schema::{
|
|||
actor_language::CommunityLanguage,
|
||||
comment::Comment,
|
||||
comment_reply::{CommentReply, CommentReplyInsertForm},
|
||||
person::Person,
|
||||
person_mention::{PersonMention, PersonMentionInsertForm},
|
||||
},
|
||||
traits::Crud,
|
||||
|
@ -74,15 +73,21 @@ pub async fn build_community_response(
|
|||
pub async fn build_post_response(
|
||||
context: &LemmyContext,
|
||||
community_id: CommunityId,
|
||||
person: &Person,
|
||||
local_user_view: LocalUserView,
|
||||
post_id: PostId,
|
||||
) -> LemmyResult<Json<PostResponse>> {
|
||||
let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), person, community_id)
|
||||
let local_user = local_user_view.local_user;
|
||||
let is_mod_or_admin = is_mod_or_admin(&mut context.pool(), &local_user_view.person, community_id)
|
||||
.await
|
||||
.is_ok();
|
||||
let post_view = PostView::read(&mut context.pool(), post_id, None, is_mod_or_admin)
|
||||
.await?
|
||||
.ok_or(LemmyErrorType::CouldntFindPost)?;
|
||||
let post_view = PostView::read(
|
||||
&mut context.pool(),
|
||||
post_id,
|
||||
Some(&local_user),
|
||||
is_mod_or_admin,
|
||||
)
|
||||
.await?
|
||||
.ok_or(LemmyErrorType::CouldntFindPost)?;
|
||||
Ok(Json(PostResponse { post_view }))
|
||||
}
|
||||
|
||||
|
|
|
@ -208,5 +208,5 @@ pub async fn create_post(
|
|||
}
|
||||
};
|
||||
|
||||
build_post_response(&context, community_id, &local_user_view.person, post_id).await
|
||||
build_post_response(&context, community_id, local_user_view, post_id).await
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ pub async fn delete_post(
|
|||
build_post_response(
|
||||
&context,
|
||||
orig_post.community_id,
|
||||
&local_user_view.person,
|
||||
local_user_view,
|
||||
data.post_id,
|
||||
)
|
||||
.await
|
||||
|
|
|
@ -73,11 +73,5 @@ pub async fn remove_post(
|
|||
)
|
||||
.await?;
|
||||
|
||||
build_post_response(
|
||||
&context,
|
||||
orig_post.community_id,
|
||||
&local_user_view.person,
|
||||
post_id,
|
||||
)
|
||||
.await
|
||||
build_post_response(&context, orig_post.community_id, local_user_view, post_id).await
|
||||
}
|
||||
|
|
|
@ -137,7 +137,7 @@ pub async fn update_post(
|
|||
build_post_response(
|
||||
context.deref(),
|
||||
orig_post.community_id,
|
||||
&local_user_view.person,
|
||||
local_user_view,
|
||||
post_id,
|
||||
)
|
||||
.await
|
||||
|
|
Loading…
Reference in New Issue