From 93b5c0cd4a9be6203bb28fda9d4d337bc6ff60cc Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 18 Apr 2024 04:50:06 +0200 Subject: [PATCH] fix: only fetch remote objects to avoid recursion --- src/routes/activitypub/activity.rs | 2 +- src/routes/activitypub/object.rs | 2 +- src/routes/activitypub/user/mod.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/activitypub/activity.rs b/src/routes/activitypub/activity.rs index 0d4ecdc..a66b053 100644 --- a/src/routes/activitypub/activity.rs +++ b/src/routes/activitypub/activity.rs @@ -39,7 +39,7 @@ pub async fn view( .await? { Some(activity) => Ok(JsonLD(serde_json::Value::from(activity).ld_context())), - None => if auth.is_local() && query.fetch { + None => if auth.is_local() && query.fetch && !ctx.is_local(&aid) { Ok(JsonLD(ap_activity(ctx.fetch().activity(&aid).await?).ld_context())) } else { Err(UpubError::not_found()) diff --git a/src/routes/activitypub/object.rs b/src/routes/activitypub/object.rs index 72301fe..6555542 100644 --- a/src/routes/activitypub/object.rs +++ b/src/routes/activitypub/object.rs @@ -44,7 +44,7 @@ pub async fn view( { Some(EmbeddedActivity { activity: _, object: Some(object) }) => Ok(JsonLD(ap_object(object).ld_context())), Some(EmbeddedActivity { activity: _, object: None }) => Err(UpubError::not_found()), - None => if auth.is_local() && query.fetch { + None => if auth.is_local() && query.fetch && !ctx.is_local(&oid) { Ok(JsonLD(ap_object(ctx.fetch().object(&oid).await?).ld_context())) } else { Err(UpubError::not_found()) diff --git a/src/routes/activitypub/user/mod.rs b/src/routes/activitypub/user/mod.rs index 19d1a4f..b2aa438 100644 --- a/src/routes/activitypub/user/mod.rs +++ b/src/routes/activitypub/user/mod.rs @@ -102,7 +102,7 @@ pub async fn view( }, // remote user TODDO doesn't work? Some((user, None)) => Ok(JsonLD(ap_user(user).ld_context())), - None => if auth.is_local() && query.fetch { + None => if auth.is_local() && query.fetch && !ctx.is_local(&uid) { Ok(JsonLD(ap_user(ctx.fetch().user(&uid).await?).ld_context())) } else { Err(UpubError::not_found())