main: let follow accept have a local id

This commit is contained in:
Astro 2023-05-26 21:57:36 +02:00
parent 5798e76d6d
commit 1b65939557
3 changed files with 15 additions and 1 deletions

7
Cargo.lock generated
View file

@ -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"

View file

@ -30,3 +30,4 @@ metrics = "0.20"
metrics-util = "0.14"
metrics-exporter-prometheus = "0.11"
deunicode = "1.3"
urlencoding = "2"

View file

@ -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(