assume well-known is None if text length exceeds 10000 chars
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
ec7aeb1096
commit
08a183e8c7
|
@ -595,14 +595,25 @@ async fn request_well_known(destination: &str) -> Option<String> {
|
||||||
.await;
|
.await;
|
||||||
debug!("Got well known response");
|
debug!("Got well known response");
|
||||||
debug!("Well known response: {:?}", response);
|
debug!("Well known response: {:?}", response);
|
||||||
|
|
||||||
if let Err(e) = &response {
|
if let Err(e) = &response {
|
||||||
debug!("Well known error: {e:?}");
|
debug!("Well known error: {e:?}");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let text = response.ok()?.text().await;
|
let text = response.ok()?.text().await;
|
||||||
|
|
||||||
debug!("Got well known response text");
|
debug!("Got well known response text");
|
||||||
debug!("Well known response text: {:?}", text);
|
debug!("Well known response text: {:?}", text);
|
||||||
|
|
||||||
|
if text.as_ref().ok()?.len() > 10000 {
|
||||||
|
info!("Well known response for destination '{destination}' exceeded past 10000 characters, assuming no well-known.");
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
let body: serde_json::Value = serde_json::from_str(&text.ok()?).ok()?;
|
let body: serde_json::Value = serde_json::from_str(&text.ok()?).ok()?;
|
||||||
|
debug!("serde_json body of well known text: {}", body);
|
||||||
|
|
||||||
Some(body.get("m.server")?.as_str()?.to_owned())
|
Some(body.get("m.server")?.as_str()?.to_owned())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue