mirror of
https://github.com/LemmyNet/activitypub-federation-rust.git
synced 2024-05-19 09:28:04 +00:00
fix lemmy tests
This commit is contained in:
parent
c026827672
commit
d1e1a41d41
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue