fix lemmy tests

This commit is contained in:
Felix Ableitner 2024-04-08 17:09:16 +02:00
parent c026827672
commit d1e1a41d41
2 changed files with 9 additions and 8 deletions

View file

@ -74,6 +74,12 @@ pub async fn fetch_object_http<T: Clone, Kind: DeserializeOwned>(
return Err(Error::FetchWrongId(res.url));
}
// Dont allow fetching local object. Only check this after the request as a local url
// may redirect to a remote object.
if data.config.is_local_url(&res.url) {
return Err(Error::NotFound);
}
Ok(res)
}
@ -124,12 +130,6 @@ async fn fetch_object_http_with_accept<T: Clone, Kind: DeserializeOwned>(
let text = res.bytes_limited().await?;
let object_id = extract_id(&text).ok();
// Dont allow fetching local object. Only check this after the request as a local url
// may redirect to a remote object.
if data.config.is_local_url(&url) {
return Err(Error::NotFound);
}
match serde_json::from_slice(&text) {
Ok(object) => Ok(FetchObjectResponse {
object,

View file

@ -91,9 +91,10 @@ where
// object found in database
if let Some(object) = db_object {
// object is old and should be refetched
if let Some(last_refreshed_at) = object.last_refreshed_at() {
if should_refetch_object(last_refreshed_at) {
let is_local = data.config.is_local_url(&self.0);
if !is_local && should_refetch_object(last_refreshed_at) {
// object is outdated and should be refetched
return self.dereference_from_http(data, Some(object)).await;
}
}