From 1b65939557f6538dda02690644bf489dc528f222 Mon Sep 17 00:00:00 2001 From: Astro Date: Fri, 26 May 2023 21:57:36 +0200 Subject: [PATCH] main: let follow accept have a local id --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/main.rs | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 5c15f77..a32d757 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -255,6 +255,7 @@ dependencies = [ "tokio-postgres", "tracing", "tracing-subscriber", + "urlencoding", ] [[package]] @@ -2090,6 +2091,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "urlencoding" +version = "2.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8db7427f936968176eaa7cdf81b7f98b980b18495ec28f1b5791ac3bfe3eea9" + [[package]] name = "utf8-cstr" version = "0.1.6" diff --git a/Cargo.toml b/Cargo.toml index 38de600..781f3d5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,3 +30,4 @@ metrics = "0.20" metrics-util = "0.14" metrics-exporter-prometheus = "0.11" deunicode = "1.3" +urlencoding = "2" diff --git a/src/main.rs b/src/main.rs index 051763a..b0f590a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -174,12 +174,18 @@ async fn post_relay( let priv_key = state.priv_key.clone(); let client = state.client.clone(); tokio::spawn(async move { + let accept_id = format!( + "https://{}/activity/accept/{}/{}", + state.hostname, + urlencoding::encode(&target.uri()), + urlencoding::encode(&remote_actor.inbox), + ); let accept = activitypub::Action { jsonld_context: serde_json::Value::String("https://www.w3.org/ns/activitystreams".to_string()), action_type: "Accept".to_string(), actor: target.uri(), to: Some(json!(remote_actor.id.clone())), - id: action.id, + id: accept_id, object: Some(endpoint.payload), }; let result = send::send(