Removing current instance, checking for federation enabled.
This commit is contained in:
parent
f4c0248d7a
commit
b41edb35aa
1 changed files with 27 additions and 22 deletions
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue