Check view permission when reposting a post
This commit is contained in:
parent
2d2ec704a2
commit
ba52cf0be1
1 changed files with 5 additions and 1 deletions
|
@ -281,12 +281,16 @@ async fn reblog(
|
|||
) -> Result<HttpResponse, HttpError> {
|
||||
let db_client = &mut **get_database_client(&db_pool).await?;
|
||||
let current_user = get_current_user(db_client, auth.token()).await?;
|
||||
let mut post = get_post_by_id(db_client, &status_id).await?;
|
||||
if !can_view_post(db_client, Some(¤t_user), &post).await? {
|
||||
return Err(HttpError::NotFoundError("post"));
|
||||
};
|
||||
let repost_data = PostCreateData {
|
||||
repost_of_id: Some(status_id),
|
||||
..Default::default()
|
||||
};
|
||||
let repost = create_post(db_client, ¤t_user.id, repost_data).await?;
|
||||
let mut post = get_post_by_id(db_client, &status_id).await?;
|
||||
post.repost_count += 1;
|
||||
get_reposted_posts(db_client, vec![&mut post]).await?;
|
||||
get_actions_for_posts(db_client, ¤t_user.id, vec![&mut post]).await?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue