Revert "Fixing bug where comment replies wouldn't be sent to blocked instances."

This reverts commit 1349aa351a.
fix_comment_instance_block
Dessalines 2024-04-05 12:55:35 -04:00
parent 38cf4e1091
commit 8e8a48e229
2 changed files with 25 additions and 5 deletions

View File

@ -4,7 +4,7 @@ use crate::{
context::LemmyContext, context::LemmyContext,
post::PostResponse, post::PostResponse,
utils::{ utils::{
check_person_community_block, check_person_instance_community_block,
get_interface_language, get_interface_language,
is_mod_or_admin, is_mod_or_admin,
send_email_to_user, send_email_to_user,
@ -149,9 +149,10 @@ pub async fn send_local_notifs(
// Get the parent commenter local_user // Get the parent commenter local_user
let parent_creator_id = parent_comment.creator_id; let parent_creator_id = parent_comment.creator_id;
let check_blocks = check_person_community_block( let check_blocks = check_person_instance_community_block(
person.id, person.id,
parent_creator_id, parent_creator_id,
person.instance_id,
community_id, community_id,
&mut context.pool(), &mut context.pool(),
) )
@ -193,9 +194,10 @@ pub async fn send_local_notifs(
} }
} }
} else { } else {
let check_blocks = check_person_community_block( let check_blocks = check_person_instance_community_block(
person.id, person.id,
post.creator_id, post.creator_id,
person.instance_id,
community_id, community_id,
&mut context.pool(), &mut context.pool(),
) )

View File

@ -6,7 +6,7 @@ use crate::{
use chrono::{DateTime, Days, Local, TimeZone, Utc}; use chrono::{DateTime, Days, Local, TimeZone, Utc};
use enum_map::{enum_map, EnumMap}; use enum_map::{enum_map, EnumMap};
use lemmy_db_schema::{ use lemmy_db_schema::{
newtypes::{CommunityId, DbUrl, PersonId, PostId}, newtypes::{CommunityId, DbUrl, InstanceId, PersonId, PostId},
source::{ source::{
comment::{Comment, CommentUpdateForm}, comment::{Comment, CommentUpdateForm},
community::{Community, CommunityModerator, CommunityUpdateForm}, community::{Community, CommunityModerator, CommunityUpdateForm},
@ -14,6 +14,7 @@ use lemmy_db_schema::{
email_verification::{EmailVerification, EmailVerificationForm}, email_verification::{EmailVerification, EmailVerificationForm},
images::{LocalImage, RemoteImage}, images::{LocalImage, RemoteImage},
instance::Instance, instance::Instance,
instance_block::InstanceBlock,
local_site::LocalSite, local_site::LocalSite,
local_site_rate_limit::LocalSiteRateLimit, local_site_rate_limit::LocalSiteRateLimit,
local_site_url_blocklist::LocalSiteUrlBlocklist, local_site_url_blocklist::LocalSiteUrlBlocklist,
@ -275,14 +276,31 @@ async fn check_community_block(
} }
} }
/// Throws an error if a recipient has blocked an instance.
#[tracing::instrument(skip_all)] #[tracing::instrument(skip_all)]
pub async fn check_person_community_block( async fn check_instance_block(
instance_id: InstanceId,
person_id: PersonId,
pool: &mut DbPool<'_>,
) -> Result<(), LemmyError> {
let is_blocked = InstanceBlock::read(pool, person_id, instance_id).await?;
if is_blocked {
Err(LemmyErrorType::InstanceIsBlocked)?
} else {
Ok(())
}
}
#[tracing::instrument(skip_all)]
pub async fn check_person_instance_community_block(
my_id: PersonId, my_id: PersonId,
potential_blocker_id: PersonId, potential_blocker_id: PersonId,
instance_id: InstanceId,
community_id: CommunityId, community_id: CommunityId,
pool: &mut DbPool<'_>, pool: &mut DbPool<'_>,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
check_person_block(my_id, potential_blocker_id, pool).await?; check_person_block(my_id, potential_blocker_id, pool).await?;
check_instance_block(instance_id, potential_blocker_id, pool).await?;
check_community_block(community_id, potential_blocker_id, pool).await?; check_community_block(community_id, potential_blocker_id, pool).await?;
Ok(()) Ok(())
} }