]> Untitled Git - lemmy.git/commitdiff
Dont show deleted users or communities on profile page. (#2450)
authorDessalines <dessalines@users.noreply.github.com>
Wed, 28 Sep 2022 20:54:32 +0000 (16:54 -0400)
committerGitHub <noreply@github.com>
Wed, 28 Sep 2022 20:54:32 +0000 (20:54 +0000)
* Dont show deleted users or communities on profile page.

- Fixes #2448

* Fix missing communities

* Add include_deleted to resolve_actor_identifier.

crates/api/src/site/search.rs
crates/api_crud/src/comment/list.rs
crates/api_crud/src/community/read.rs
crates/api_crud/src/post/list.rs
crates/api_crud/src/user/read.rs
crates/apub/src/fetcher/mod.rs
crates/db_views_actor/src/community_block_view.rs
crates/db_views_actor/src/community_follower_view.rs
crates/db_views_actor/src/community_moderator_view.rs
crates/db_views_actor/src/person_block_view.rs
crates/db_views_actor/src/person_view.rs

index 4c27ef8930d63df78756d9d01449c2d00c593b11..9fcde746ec297229e6a17a9841a2fd33f09c5222 100644 (file)
@@ -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::<ApubCommunity, Community>(name, context)
+      resolve_actor_identifier::<ApubCommunity, Community>(name, context, false)
         .await
         .ok()
         .map(|c| c.actor_id)
index e8ff8c1800cf01cca1a8b13a7de39fb601ad7da8..92e1771c99cf1deb26ec7c74e7b8da4498da409d 100644 (file)
@@ -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::<ApubCommunity, Community>(name, context)
+      resolve_actor_identifier::<ApubCommunity, Community>(name, context, true)
         .await
         .ok()
         .map(|c| c.actor_id)
index 32668b02bd9ac9facbe0234283d3b714c3b9e6fa..fda9912210f630d2b0ba3002eb1c732f87b6b71f 100644 (file)
@@ -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::<ApubCommunity, Community>(&name, context)
+        resolve_actor_identifier::<ApubCommunity, Community>(&name, context, true)
           .await
           .map_err(|e| e.with_message("couldnt_find_community"))?
           .id
index e58ff8715b2cdee2e9a5471d194c15aecf042aba..647d6b2948c7306495e48084da0db66e0d684685 100644 (file)
@@ -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::<ApubCommunity, Community>(name, context)
+      resolve_actor_identifier::<ApubCommunity, Community>(name, context, true)
         .await
         .ok()
         .map(|c| c.actor_id)
index d60932a1e1771be94f1f7479e6f3ab8ecc588341..e77a4b3f3612fbb03d6ac1234ee866ea7ddec125 100644 (file)
@@ -37,7 +37,7 @@ impl PerformCrud for GetPersonDetails {
       Some(id) => id,
       None => {
         if let Some(username) = &data.username {
-          resolve_actor_identifier::<ApubPerson, Person>(username, context)
+          resolve_actor_identifier::<ApubPerson, Person>(username, context, true)
             .await
             .map_err(|e| e.with_message("couldnt_find_that_username_or_email"))?
             .id
index 8daef4331ac32b982b826f76dc62b9ddf9625d43..193dd686567ef92f01c86f90f608a0b5f4f591f8 100644 (file)
@@ -18,6 +18,7 @@ pub mod webfinger;
 pub async fn resolve_actor_identifier<Actor, DbActor>(
   identifier: &str,
   context: &LemmyContext,
+  include_deleted: bool,
 ) -> Result<DbActor, LemmyError>
 where
   Actor: ApubObject<DataType = LemmyContext, Error = LemmyError>
@@ -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??,
     )
index 96204e7d9a2d3cb9bff9c0d004d938ae3fa97502..6c46904a2c4cea85d669cfbf44b28c189fcc3720 100644 (file)
@@ -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::<CommunityBlockViewTuple>(conn)?;
 
index fb8ae0233fe1e7eae28bc5ef1bb268d5b2e1bfdc..51e58fdadf41cd3dbb4bb592ec70002065aa7562 100644 (file)
@@ -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::<CommunityFollowerViewTuple>(conn)?;
 
index eeda7ed66e2611d6702a86c9b938cfe5a086a090..28ad6d8493b920ac19f61bb313d94c739c569223 100644 (file)
@@ -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::<CommunityModeratorViewTuple>(conn)?;
 
index 90d56ccd7ba5615f8351b08b72eced64542fe18d..b8bb09feb577933fcee648ddb65bd2a1a2c6300b 100644 (file)
@@ -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::<PersonBlockViewTuple>(conn)?;
 
index af0927a8519f0ae503ef1c180109ce4ffd57dae7..55a64819953f35979a93c5a5c2da18b4b167896f 100644 (file)
@@ -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::<PersonViewSafeTuple>(conn)?;
 
@@ -45,6 +46,7 @@ impl PersonViewSafe {
             .or(person::ban_expires.gt(now)),
         ),
       )
+      .filter(person::deleted.eq(false))
       .load::<PersonViewSafeTuple>(conn)?;
 
     Ok(Self::from_tuple_to_vec(banned))