]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/community.rs
Be more explicit about returning deleted actors or not (#2335)
[lemmy.git] / crates / db_schema / src / impls / community.rs
index f957fb2617a258d3cd2dc79a694d0f66b3309ebb..a0a1dde2a99effd4fa2618869f6382ac0413123c 100644 (file)
@@ -332,12 +332,20 @@ impl ApubActor for Community {
     )
   }
 
-  fn read_from_name(conn: &PgConnection, community_name: &str) -> Result<Community, Error> {
+  fn read_from_name(
+    conn: &PgConnection,
+    community_name: &str,
+    include_deleted: bool,
+  ) -> Result<Community, Error> {
     use crate::schema::community::dsl::*;
-    community
+    let mut q = community
+      .into_boxed()
       .filter(local.eq(true))
-      .filter(lower(name).eq(lower(community_name)))
-      .first::<Self>(conn)
+      .filter(lower(name).eq(lower(community_name)));
+    if !include_deleted {
+      q = q.filter(deleted.eq(false)).filter(removed.eq(false));
+    }
+    q.first::<Self>(conn)
   }
 
   fn read_from_name_and_domain(