diff --git a/Cargo.lock b/Cargo.lock index 2b57535..40e06e2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1368,7 +1368,7 @@ dependencies = [ [[package]] name = "k-ap" -version = "0.1.4" +version = "0.1.5" dependencies = [ "activitypub_federation", "anyhow", diff --git a/Cargo.toml b/Cargo.toml index 17b5add..6dc608b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "k-ap" -version = "0.1.5" +version = "0.1.6" edition = "2024" description = "Generic ActivityPub protocol layer" license = "MIT" diff --git a/src/actors.rs b/src/actors.rs index f211356..f804fc7 100644 --- a/src/actors.rs +++ b/src/actors.rs @@ -193,6 +193,11 @@ pub async fn get_local_actor( }) } +fn apex_domain(url: &Url) -> String { + let host = url.host_str().unwrap_or(""); + host.strip_prefix("www.").unwrap_or(host).to_owned() +} + #[async_trait::async_trait] impl Object for DbActor { type DataType = FederationData; @@ -319,8 +324,13 @@ impl Object for DbActor { expected_domain: &Url, _data: &Data, ) -> Result<(), Self::Error> { - verify_domains_match(json.id.inner(), expected_domain)?; - Ok(()) + if verify_domains_match(json.id.inner(), expected_domain).is_ok() { + return Ok(()); + } + if apex_domain(json.id.inner()) == apex_domain(expected_domain) { + return Ok(()); + } + verify_domains_match(json.id.inner(), expected_domain).map_err(Error::from) } async fn from_json(json: Self::Kind, data: &Data) -> Result {