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());
}
let mut allowed_instances = Settings::get().get_allowed_instances();
instances.append(&mut allowed_instances);
let blocked_instances = Settings::get().get_blocked_instances();
for blocked in &blocked_instances {
instances.retain(|i| !i.eq(blocked));
}
instances.extend(Settings::get().get_allowed_instances().into_iter());
instances.retain(|a| {
!Settings::get().get_blocked_instances().contains(a)
&& !a.eq("")
&& !a.eq(&Settings::get().hostname)
});
// Sort and remove dupes
instances.sort_unstable();
instances.dedup();
// Remove the empties
instances.retain(|d| !d.eq(""));
// Remove the current instance
instances.retain(|d| !d.eq(&Settings::get().hostname));
}
Ok(instances)