Cleaning up.

This commit is contained in:
Dessalines 2020-09-23 08:41:45 -05:00
parent b41edb35aa
commit 63cf0a8eb6

View file

@ -111,23 +111,16 @@ pub(in crate::api) async fn linked_instances(pool: &DbPool) -> Result<Vec<String
instances.push(Url::parse(actor_id)?.host_str().unwrap_or("").to_string()); instances.push(Url::parse(actor_id)?.host_str().unwrap_or("").to_string());
} }
let mut allowed_instances = Settings::get().get_allowed_instances(); instances.extend(Settings::get().get_allowed_instances().into_iter());
instances.append(&mut allowed_instances); instances.retain(|a| {
!Settings::get().get_blocked_instances().contains(a)
let blocked_instances = Settings::get().get_blocked_instances(); && !a.eq("")
for blocked in &blocked_instances { && !a.eq(&Settings::get().hostname)
instances.retain(|i| !i.eq(blocked)); });
}
// Sort and remove dupes // Sort and remove dupes
instances.sort_unstable(); instances.sort_unstable();
instances.dedup(); instances.dedup();
// Remove the empties
instances.retain(|d| !d.eq(""));
// Remove the current instance
instances.retain(|d| !d.eq(&Settings::get().hostname));
} }
Ok(instances) Ok(instances)