mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-22 14:45:10 +00:00
* Allow comment replies from blocked users. Fixes #1793 * Clearer check block.
This commit is contained in:
parent
040770d7ba
commit
4e9ecb2632
|
@ -4,7 +4,6 @@ use lemmy_api_common::{
|
||||||
blocking,
|
blocking,
|
||||||
check_community_ban,
|
check_community_ban,
|
||||||
check_community_deleted_or_removed,
|
check_community_deleted_or_removed,
|
||||||
check_person_block,
|
|
||||||
check_post_deleted_or_removed,
|
check_post_deleted_or_removed,
|
||||||
comment::*,
|
comment::*,
|
||||||
get_local_user_view_from_jwt,
|
get_local_user_view_from_jwt,
|
||||||
|
@ -66,8 +65,6 @@ impl PerformCrud for CreateComment {
|
||||||
check_community_deleted_or_removed(community_id, context.pool()).await?;
|
check_community_deleted_or_removed(community_id, context.pool()).await?;
|
||||||
check_post_deleted_or_removed(&post)?;
|
check_post_deleted_or_removed(&post)?;
|
||||||
|
|
||||||
check_person_block(local_user_view.person.id, post.creator_id, context.pool()).await?;
|
|
||||||
|
|
||||||
// Check if post is locked, no new comments
|
// Check if post is locked, no new comments
|
||||||
if post.locked {
|
if post.locked {
|
||||||
return Err(ApiError::err_plain("locked").into());
|
return Err(ApiError::err_plain("locked").into());
|
||||||
|
@ -80,8 +77,6 @@ impl PerformCrud for CreateComment {
|
||||||
.await?
|
.await?
|
||||||
.map_err(|e| ApiError::err("couldnt_create_comment", e))?;
|
.map_err(|e| ApiError::err("couldnt_create_comment", e))?;
|
||||||
|
|
||||||
check_person_block(local_user_view.person.id, parent.creator_id, context.pool()).await?;
|
|
||||||
|
|
||||||
// Strange issue where sometimes the post ID is incorrect
|
// Strange issue where sometimes the post ID is incorrect
|
||||||
if parent.post_id != post_id {
|
if parent.post_id != post_id {
|
||||||
return Err(ApiError::err_plain("couldnt_create_comment").into());
|
return Err(ApiError::err_plain("couldnt_create_comment").into());
|
||||||
|
|
|
@ -5,6 +5,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use lemmy_api_common::{
|
use lemmy_api_common::{
|
||||||
blocking,
|
blocking,
|
||||||
|
check_person_block,
|
||||||
comment::CommentResponse,
|
comment::CommentResponse,
|
||||||
community::CommunityResponse,
|
community::CommunityResponse,
|
||||||
person::PrivateMessageResponse,
|
person::PrivateMessageResponse,
|
||||||
|
@ -233,11 +234,18 @@ pub async fn send_local_notifs(
|
||||||
let parent_comment =
|
let parent_comment =
|
||||||
blocking(context.pool(), move |conn| Comment::read(conn, parent_id)).await?;
|
blocking(context.pool(), move |conn| Comment::read(conn, parent_id)).await?;
|
||||||
if let Ok(parent_comment) = parent_comment {
|
if let Ok(parent_comment) = parent_comment {
|
||||||
// Don't send a notif to yourself
|
|
||||||
if parent_comment.creator_id != person.id {
|
|
||||||
// Get the parent commenter local_user
|
// Get the parent commenter local_user
|
||||||
|
let parent_creator_id = parent_comment.creator_id;
|
||||||
|
|
||||||
|
// Only add to recipients if that person isn't blocked
|
||||||
|
let creator_blocked = check_person_block(person.id, parent_creator_id, context.pool())
|
||||||
|
.await
|
||||||
|
.is_err();
|
||||||
|
|
||||||
|
// Don't send a notif to yourself
|
||||||
|
if parent_comment.creator_id != person.id && !creator_blocked {
|
||||||
let user_view = blocking(context.pool(), move |conn| {
|
let user_view = blocking(context.pool(), move |conn| {
|
||||||
LocalUserView::read_person(conn, parent_comment.creator_id)
|
LocalUserView::read_person(conn, parent_creator_id)
|
||||||
})
|
})
|
||||||
.await?;
|
.await?;
|
||||||
if let Ok(parent_user_view) = user_view {
|
if let Ok(parent_user_view) = user_view {
|
||||||
|
@ -257,8 +265,14 @@ pub async fn send_local_notifs(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Its a post
|
// Its a post
|
||||||
|
// Don't send a notif to yourself
|
||||||
None => {
|
None => {
|
||||||
if post.creator_id != person.id {
|
// Only add to recipients if that person isn't blocked
|
||||||
|
let creator_blocked = check_person_block(person.id, post.creator_id, context.pool())
|
||||||
|
.await
|
||||||
|
.is_err();
|
||||||
|
|
||||||
|
if post.creator_id != person.id && !creator_blocked {
|
||||||
let creator_id = post.creator_id;
|
let creator_id = post.creator_id;
|
||||||
let parent_user = blocking(context.pool(), move |conn| {
|
let parent_user = blocking(context.pool(), move |conn| {
|
||||||
LocalUserView::read_person(conn, creator_id)
|
LocalUserView::read_person(conn, creator_id)
|
||||||
|
|
Loading…
Reference in a new issue