Don't overwrite listener URI

This commit is contained in:
asonix 2020-06-20 10:06:01 -05:00
parent f9b036fe4e
commit bc1003c467
2 changed files with 12 additions and 10 deletions

View file

@ -20,7 +20,7 @@ impl QueryInstance {
} }
} }
async fn perform(mut self, state: JobState) -> Result<(), Error> { async fn perform(self, state: JobState) -> Result<(), Error> {
let (o1, o2) = join!( let (o1, o2) = join!(
state.node_cache.is_contact_outdated(&self.listener), state.node_cache.is_contact_outdated(&self.listener),
state.node_cache.is_instance_outdated(&self.listener), state.node_cache.is_instance_outdated(&self.listener),
@ -30,13 +30,14 @@ impl QueryInstance {
return Ok(()); return Ok(());
} }
self.listener.set_fragment(None); let mut instance_uri = self.listener.clone();
self.listener.set_query(None); instance_uri.set_fragment(None);
self.listener.set_path("api/v1/instance"); instance_uri.set_query(None);
instance_uri.set_path("api/v1/instance");
let instance = state let instance = state
.requests .requests
.fetch::<Instance>(self.listener.as_str()) .fetch::<Instance>(instance_uri.as_str())
.await?; .await?;
let description = if instance.description.is_empty() { let description = if instance.description.is_empty() {

View file

@ -16,18 +16,19 @@ impl QueryNodeinfo {
} }
} }
async fn perform(mut self, state: JobState) -> Result<(), Error> { async fn perform(self, state: JobState) -> Result<(), Error> {
if !state.node_cache.is_nodeinfo_outdated(&self.listener).await { if !state.node_cache.is_nodeinfo_outdated(&self.listener).await {
return Ok(()); return Ok(());
} }
self.listener.set_fragment(None); let mut well_known_uri = self.listener.clone();
self.listener.set_query(None); well_known_uri.set_fragment(None);
self.listener.set_path(".well-known/nodeinfo"); well_known_uri.set_query(None);
well_known_uri.set_path(".well-known/nodeinfo");
let well_known = state let well_known = state
.requests .requests
.fetch::<WellKnown>(self.listener.as_str()) .fetch::<WellKnown>(well_known_uri.as_str())
.await?; .await?;
let href = if let Some(link) = well_known.links.into_iter().find(|l| l.rel.is_supported()) { let href = if let Some(link) = well_known.links.into_iter().find(|l| l.rel.is_supported()) {