mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-03 03:33:50 +00:00
Fix post like not decrementing vote totals. (#5941)
* Fix post like not decrementing vote totals. - Issue was: reading the original post like didn't pass my user, so it couldn't grab post_actions.like_score. - Fixes #5940 * Add a few more local_user passes to PostView::read * Forgot another
This commit is contained in:
parent
60b5bf5c0e
commit
b7a9eb05da
5 changed files with 47 additions and 17 deletions
|
@ -45,8 +45,14 @@ pub async fn like_post(
|
||||||
check_bot_account(&local_user_view.person)?;
|
check_bot_account(&local_user_view.person)?;
|
||||||
|
|
||||||
// Check for a community ban
|
// Check for a community ban
|
||||||
let orig_post =
|
let orig_post = PostView::read(
|
||||||
PostView::read(&mut context.pool(), post_id, None, local_instance_id, false).await?;
|
&mut context.pool(),
|
||||||
|
post_id,
|
||||||
|
Some(&local_user_view.local_user),
|
||||||
|
local_instance_id,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
let previous_score = orig_post.post_actions.and_then(|p| p.like_score);
|
let previous_score = orig_post.post_actions.and_then(|p| p.like_score);
|
||||||
|
|
||||||
check_community_user_action(&local_user_view, &orig_post.community, &mut context.pool()).await?;
|
check_community_user_action(&local_user_view, &orig_post.community, &mut context.pool()).await?;
|
||||||
|
|
|
@ -28,8 +28,14 @@ pub async fn lock_post(
|
||||||
let post_id = data.post_id;
|
let post_id = data.post_id;
|
||||||
let local_instance_id = local_user_view.person.instance_id;
|
let local_instance_id = local_user_view.person.instance_id;
|
||||||
|
|
||||||
let orig_post =
|
let orig_post = PostView::read(
|
||||||
PostView::read(&mut context.pool(), post_id, None, local_instance_id, false).await?;
|
&mut context.pool(),
|
||||||
|
post_id,
|
||||||
|
Some(&local_user_view.local_user),
|
||||||
|
local_instance_id,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
check_community_mod_action(
|
check_community_mod_action(
|
||||||
&local_user_view,
|
&local_user_view,
|
||||||
|
|
|
@ -37,8 +37,14 @@ pub async fn mod_update_post(
|
||||||
check_nsfw_allowed(data.nsfw, Some(&local_site))?;
|
check_nsfw_allowed(data.nsfw, Some(&local_site))?;
|
||||||
|
|
||||||
let post_id = data.post_id;
|
let post_id = data.post_id;
|
||||||
let orig_post =
|
let orig_post = PostView::read(
|
||||||
PostView::read(&mut context.pool(), post_id, None, local_instance_id, false).await?;
|
&mut context.pool(),
|
||||||
|
post_id,
|
||||||
|
Some(&local_user_view.local_user),
|
||||||
|
local_instance_id,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
let community = orig_post.community;
|
let community = orig_post.community;
|
||||||
|
|
||||||
check_community_user_action(&local_user_view, &community, &mut context.pool()).await?;
|
check_community_user_action(&local_user_view, &community, &mut context.pool()).await?;
|
||||||
|
|
|
@ -34,19 +34,25 @@ pub async fn create_post_report(
|
||||||
let person = &local_user_view.person;
|
let person = &local_user_view.person;
|
||||||
let post_id = data.post_id;
|
let post_id = data.post_id;
|
||||||
let local_instance_id = local_user_view.person.instance_id;
|
let local_instance_id = local_user_view.person.instance_id;
|
||||||
let post_view =
|
let orig_post = PostView::read(
|
||||||
PostView::read(&mut context.pool(), post_id, None, local_instance_id, false).await?;
|
&mut context.pool(),
|
||||||
|
post_id,
|
||||||
|
Some(&local_user_view.local_user),
|
||||||
|
local_instance_id,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
check_community_user_action(&local_user_view, &post_view.community, &mut context.pool()).await?;
|
check_community_user_action(&local_user_view, &orig_post.community, &mut context.pool()).await?;
|
||||||
|
|
||||||
check_post_deleted_or_removed(&post_view.post)?;
|
check_post_deleted_or_removed(&orig_post.post)?;
|
||||||
|
|
||||||
let report_form = PostReportForm {
|
let report_form = PostReportForm {
|
||||||
creator_id: person.id,
|
creator_id: person.id,
|
||||||
post_id,
|
post_id,
|
||||||
original_post_name: post_view.post.name,
|
original_post_name: orig_post.post.name,
|
||||||
original_post_url: post_view.post.url,
|
original_post_url: orig_post.post.url,
|
||||||
original_post_body: post_view.post.body,
|
original_post_body: orig_post.post.body,
|
||||||
reason,
|
reason,
|
||||||
violates_instance_rules: data.violates_instance_rules.unwrap_or_default(),
|
violates_instance_rules: data.violates_instance_rules.unwrap_or_default(),
|
||||||
};
|
};
|
||||||
|
@ -70,9 +76,9 @@ pub async fn create_post_report(
|
||||||
|
|
||||||
ActivityChannel::submit_activity(
|
ActivityChannel::submit_activity(
|
||||||
SendActivityData::CreateReport {
|
SendActivityData::CreateReport {
|
||||||
object_id: post_view.post.ap_id.inner().clone(),
|
object_id: orig_post.post.ap_id.inner().clone(),
|
||||||
actor: local_user_view.person,
|
actor: local_user_view.person,
|
||||||
receiver: Either::Right(post_view.community),
|
receiver: Either::Right(orig_post.community),
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
},
|
},
|
||||||
&context,
|
&context,
|
||||||
|
|
|
@ -97,8 +97,14 @@ pub async fn update_post(
|
||||||
}
|
}
|
||||||
|
|
||||||
let post_id = data.post_id;
|
let post_id = data.post_id;
|
||||||
let orig_post =
|
let orig_post = PostView::read(
|
||||||
PostView::read(&mut context.pool(), post_id, None, local_instance_id, false).await?;
|
&mut context.pool(),
|
||||||
|
post_id,
|
||||||
|
Some(&local_user_view.local_user),
|
||||||
|
local_instance_id,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
check_community_user_action(&local_user_view, &orig_post.community, &mut context.pool()).await?;
|
check_community_user_action(&local_user_view, &orig_post.community, &mut context.pool()).await?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue