From: Dessalines Date: Wed, 28 Sep 2022 20:54:32 +0000 (-0400) Subject: Dont show deleted users or communities on profile page. (#2450) X-Git-Url: http://these/git/readmes/%24%7B%60data:application/%7BpictrsAvatarThumbnail%28community.icon%29%7D?a=commitdiff_plain;h=ee416543943a82e552177c9f4ca67d8b1fb15dc2;p=lemmy.git Dont show deleted users or communities on profile page. (#2450) * Dont show deleted users or communities on profile page. - Fixes #2448 * Fix missing communities * Add include_deleted to resolve_actor_identifier. --- diff --git a/crates/api/src/site/search.rs b/crates/api/src/site/search.rs index 4c27ef89..9fcde746 100644 --- a/crates/api/src/site/search.rs +++ b/crates/api/src/site/search.rs @@ -51,7 +51,7 @@ impl Perform for Search { let search_type = data.type_.unwrap_or(SearchType::All); let community_id = data.community_id; let community_actor_id = if let Some(name) = &data.community_name { - resolve_actor_identifier::(name, context) + resolve_actor_identifier::(name, context, false) .await .ok() .map(|c| c.actor_id) diff --git a/crates/api_crud/src/comment/list.rs b/crates/api_crud/src/comment/list.rs index e8ff8c18..92e1771c 100644 --- a/crates/api_crud/src/comment/list.rs +++ b/crates/api_crud/src/comment/list.rs @@ -38,7 +38,7 @@ impl PerformCrud for GetComments { let listing_type = listing_type_with_site_default(data.type_, context.pool()).await?; let community_actor_id = if let Some(name) = &data.community_name { - resolve_actor_identifier::(name, context) + resolve_actor_identifier::(name, context, true) .await .ok() .map(|c| c.actor_id) diff --git a/crates/api_crud/src/community/read.rs b/crates/api_crud/src/community/read.rs index 32668b02..fda99122 100644 --- a/crates/api_crud/src/community/read.rs +++ b/crates/api_crud/src/community/read.rs @@ -43,7 +43,7 @@ impl PerformCrud for GetCommunity { Some(id) => id, None => { let name = data.name.to_owned().unwrap_or_else(|| "main".to_string()); - resolve_actor_identifier::(&name, context) + resolve_actor_identifier::(&name, context, true) .await .map_err(|e| e.with_message("couldnt_find_community"))? .id diff --git a/crates/api_crud/src/post/list.rs b/crates/api_crud/src/post/list.rs index e58ff871..647d6b29 100644 --- a/crates/api_crud/src/post/list.rs +++ b/crates/api_crud/src/post/list.rs @@ -41,7 +41,7 @@ impl PerformCrud for GetPosts { let limit = data.limit; let community_id = data.community_id; let community_actor_id = if let Some(name) = &data.community_name { - resolve_actor_identifier::(name, context) + resolve_actor_identifier::(name, context, true) .await .ok() .map(|c| c.actor_id) diff --git a/crates/api_crud/src/user/read.rs b/crates/api_crud/src/user/read.rs index d60932a1..e77a4b3f 100644 --- a/crates/api_crud/src/user/read.rs +++ b/crates/api_crud/src/user/read.rs @@ -37,7 +37,7 @@ impl PerformCrud for GetPersonDetails { Some(id) => id, None => { if let Some(username) = &data.username { - resolve_actor_identifier::(username, context) + resolve_actor_identifier::(username, context, true) .await .map_err(|e| e.with_message("couldnt_find_that_username_or_email"))? .id diff --git a/crates/apub/src/fetcher/mod.rs b/crates/apub/src/fetcher/mod.rs index 8daef433..193dd686 100644 --- a/crates/apub/src/fetcher/mod.rs +++ b/crates/apub/src/fetcher/mod.rs @@ -18,6 +18,7 @@ pub mod webfinger; pub async fn resolve_actor_identifier( identifier: &str, context: &LemmyContext, + include_deleted: bool, ) -> Result where Actor: ApubObject @@ -58,7 +59,7 @@ where let identifier = identifier.to_string(); Ok( blocking(context.pool(), move |conn| { - DbActor::read_from_name(conn, &identifier, false) + DbActor::read_from_name(conn, &identifier, include_deleted) }) .await??, ) diff --git a/crates/db_views_actor/src/community_block_view.rs b/crates/db_views_actor/src/community_block_view.rs index 96204e7d..6c46904a 100644 --- a/crates/db_views_actor/src/community_block_view.rs +++ b/crates/db_views_actor/src/community_block_view.rs @@ -22,6 +22,8 @@ impl CommunityBlockView { Community::safe_columns_tuple(), )) .filter(community_block::person_id.eq(person_id)) + .filter(community::deleted.eq(false)) + .filter(community::removed.eq(false)) .order_by(community_block::published) .load::(conn)?; diff --git a/crates/db_views_actor/src/community_follower_view.rs b/crates/db_views_actor/src/community_follower_view.rs index fb8ae023..51e58fda 100644 --- a/crates/db_views_actor/src/community_follower_view.rs +++ b/crates/db_views_actor/src/community_follower_view.rs @@ -40,6 +40,8 @@ impl CommunityFollowerView { Person::safe_columns_tuple(), )) .filter(community_follower::person_id.eq(person_id)) + .filter(community::deleted.eq(false)) + .filter(community::removed.eq(false)) .order_by(community::title) .load::(conn)?; diff --git a/crates/db_views_actor/src/community_moderator_view.rs b/crates/db_views_actor/src/community_moderator_view.rs index eeda7ed6..28ad6d84 100644 --- a/crates/db_views_actor/src/community_moderator_view.rs +++ b/crates/db_views_actor/src/community_moderator_view.rs @@ -40,6 +40,8 @@ impl CommunityModeratorView { Person::safe_columns_tuple(), )) .filter(community_moderator::person_id.eq(person_id)) + .filter(community::deleted.eq(false)) + .filter(community::removed.eq(false)) .order_by(community_moderator::published) .load::(conn)?; diff --git a/crates/db_views_actor/src/person_block_view.rs b/crates/db_views_actor/src/person_block_view.rs index 90d56ccd..b8bb09fe 100644 --- a/crates/db_views_actor/src/person_block_view.rs +++ b/crates/db_views_actor/src/person_block_view.rs @@ -21,6 +21,7 @@ impl PersonBlockView { person_alias_1.fields(Person::safe_columns_tuple()), )) .filter(person_block::person_id.eq(person_id)) + .filter(person_alias_1.field(person::deleted).eq(false)) .order_by(person_block::published) .load::(conn)?; diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index af0927a8..55a64819 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -28,6 +28,7 @@ impl PersonViewSafe { .inner_join(person_aggregates::table) .select((Person::safe_columns_tuple(), person_aggregates::all_columns)) .filter(person::admin.eq(true)) + .filter(person::deleted.eq(false)) .order_by(person::published) .load::(conn)?; @@ -45,6 +46,7 @@ impl PersonViewSafe { .or(person::ban_expires.gt(now)), ), ) + .filter(person::deleted.eq(false)) .load::(conn)?; Ok(Self::from_tuple_to_vec(banned))