Removing current instance, checking for federation enabled.

This commit is contained in:
Dessalines 2020-09-22 21:12:42 -05:00
parent f4c0248d7a
commit b41edb35aa

View file

@ -99,13 +99,14 @@ pub(in crate::api) async fn check_community_ban(
}
pub(in crate::api) async fn linked_instances(pool: &DbPool) -> Result<Vec<String>, LemmyError> {
let mut instances: Vec<String> = Vec::new();
if Settings::get().federation.enabled {
let distinct_communities = blocking(pool, move |conn| {
Community::distinct_federated_communities(conn)
})
.await??;
let mut instances: Vec<String> = Vec::new();
for actor_id in &distinct_communities {
instances.push(Url::parse(actor_id)?.host_str().unwrap_or("").to_string());
}
@ -125,5 +126,9 @@ pub(in crate::api) async fn linked_instances(pool: &DbPool) -> Result<Vec<String
// Remove the empties
instances.retain(|d| !d.eq(""));
// Remove the current instance
instances.retain(|d| !d.eq(&Settings::get().hostname));
}
Ok(instances)
}