From 9059de856934b1673e6abf0444002cad94f0a9ba Mon Sep 17 00:00:00 2001 From: Nutomic Date: Wed, 10 Apr 2024 16:04:57 +0200 Subject: [PATCH] Allow fetching from local url, add fetch redirect test (fixes #4526) (#4607) * Allow fetching from local url, at fetch redirect test (fixes #4526) * prettier * update lib * update apub lib --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- api_tests/src/post.spec.ts | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c0edf2dcf..e2561e7a3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -16,9 +16,9 @@ checksum = "8f27d075294830fcab6f66e320dab524bc6d048f4a151698e153205559113772" [[package]] name = "activitypub_federation" -version = "0.5.2" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a028034c642d3ed16b535f98f48b3df30397833c183d68852d79de16650d5ed5" +checksum = "7f2a21d597eb09353bc83bea36095e1de0ef5297a6fe16edba3de676898a5ba9" dependencies = [ "activitystreams-kinds", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 554448d02..8175cd68f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -99,7 +99,7 @@ lemmy_db_views = { version = "=0.19.4-beta.2", path = "./crates/db_views" } lemmy_db_views_actor = { version = "=0.19.4-beta.2", path = "./crates/db_views_actor" } lemmy_db_views_moderator = { version = "=0.19.4-beta.2", path = "./crates/db_views_moderator" } lemmy_federate = { version = "=0.19.4-beta.2", path = "./crates/federate" } -activitypub_federation = { version = "0.5.2", default-features = false, features = [ +activitypub_federation = { version = "0.5.3", default-features = false, features = [ "actix-web", ] } diesel = "2.1.4" diff --git a/api_tests/src/post.spec.ts b/api_tests/src/post.spec.ts index c1640e93e..75f965431 100644 --- a/api_tests/src/post.spec.ts +++ b/api_tests/src/post.spec.ts @@ -745,3 +745,23 @@ test("Block post that contains banned URL", async () => { editSiteForm.blocked_urls = []; await epsilon.editSite(editSiteForm); }); + +test("Fetch post with redirect", async () => { + let alphaPost = await createPost(alpha, betaCommunity!.community.id); + expect(alphaPost.post_view.post).toBeDefined(); + + // beta fetches from alpha as usual + let betaPost = await resolvePost(beta, alphaPost.post_view.post); + expect(betaPost.post).toBeDefined(); + + // gamma fetches from beta, and gets redirected to alpha + let gammaPost = await resolvePost(gamma, betaPost.post!.post); + expect(gammaPost.post).toBeDefined(); + + // fetch remote object from local url, which redirects to the original url + let form: ResolveObject = { + q: `http://lemmy-gamma:8561/post/${gammaPost.post!.post.id}`, + }; + let gammaPost2 = await gamma.resolveObject(form); + expect(gammaPost2.post).toBeDefined(); +});