From: Bao <qubidt@gmail.com> Date: Thu, 27 Jul 2023 10:12:18 +0000 (-0500) Subject: Omit local instance from federated instances list (#3712) X-Git-Url: http://these/git/%7B%60%24%7BarchiveTodayUrl%7D/%22https:/hacktivis.me/%22?a=commitdiff_plain;h=2d7b416652c7f5afe72cfcf9c0fdc082d53e922e;p=lemmy.git Omit local instance from federated instances list (#3712) Co-authored-by: Nutomic <me@nutomic.com> --- diff --git a/crates/db_schema/src/impls/instance.rs b/crates/db_schema/src/impls/instance.rs index d6a23a71..f92d261b 100644 --- a/crates/db_schema/src/impls/instance.rs +++ b/crates/db_schema/src/impls/instance.rs @@ -1,7 +1,7 @@ use crate::{ diesel::dsl::IntervalDsl, newtypes::InstanceId, - schema::{federation_allowlist, federation_blocklist, instance}, + schema::{federation_allowlist, federation_blocklist, instance, local_site, site}, source::instance::{Instance, InstanceForm}, utils::{get_conn, naive_now, DbPool}, }; @@ -97,6 +97,10 @@ impl Instance { pub async fn linked(pool: &mut DbPool<'_>) -> Result<Vec<Self>, Error> { let conn = &mut get_conn(pool).await?; instance::table + // omit instance representing the local site + .left_join(site::table.inner_join(local_site::table)) + .filter(local_site::id.is_null()) + // omit instances in the blocklist .left_join(federation_blocklist::table) .filter(federation_blocklist::id.is_null()) .select(instance::all_columns)