diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index b61dcc93..2c27475f 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -295,26 +295,26 @@ impl Link for Id {} #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] -pub struct ApSignature07 { - pub public_key: PublicKey07, +pub struct ApSignature { + pub public_key: PublicKey, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] -pub struct PublicKey07 { +pub struct PublicKey { pub id: IriString, pub owner: IriString, pub public_key_pem: String, } -impl UnparsedExtension for ApSignature07 +impl UnparsedExtension for ApSignature where U: UnparsedMutExt, { type Error = serde_json::Error; fn try_from_unparsed(unparsed_mut: &mut U) -> Result { - Ok(ApSignature07 { + Ok(ApSignature { public_key: unparsed_mut.remove("publicKey")?, }) } @@ -349,8 +349,8 @@ where } } -pub type CustomPerson = Ext1, ApSignature07>; -pub type CustomGroup = Ext2, ApSignature07, SourceProperty>; +pub type CustomPerson = Ext1, ApSignature>; +pub type CustomGroup = Ext2, ApSignature, SourceProperty>; kind!(HashtagType, Hashtag); @@ -584,8 +584,8 @@ mod tests { #[test] fn se_ap_signature() { - let ap_signature = ApSignature07 { - public_key: PublicKey07 { + let ap_signature = ApSignature { + public_key: PublicKey { id: "https://example.com/pubkey".parse().unwrap(), owner: "https://example.com/owner".parse().unwrap(), public_key_pem: "pubKeyPem".into(), @@ -603,7 +603,7 @@ mod tests { #[test] fn de_ap_signature() { - let value: ApSignature07 = from_str( + let value: ApSignature = from_str( r#" { "publicKey": { @@ -615,8 +615,8 @@ mod tests { "#, ) .unwrap(); - let expected = ApSignature07 { - public_key: PublicKey07 { + let expected = ApSignature { + public_key: PublicKey { id: "https://example.com/".parse().unwrap(), owner: "https://example.com/".parse().unwrap(), public_key_pem: "".into(), @@ -630,8 +630,8 @@ mod tests { let actor = ApActor::new("https://example.com/inbox".parse().unwrap(), Person::new()); let person = CustomPerson::new( actor, - ApSignature07 { - public_key: PublicKey07 { + ApSignature { + public_key: PublicKey { id: "https://example.com/pubkey".parse().unwrap(), owner: "https://example.com/owner".parse().unwrap(), public_key_pem: "pubKeyPem".into(), diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 96aec540..94fafba2 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -20,8 +20,8 @@ use openssl::{ }; use plume_common::activity_pub::{ inbox::{AsActor, FromId}, - sign, ActivityStream, ApSignature07, CustomGroup, Id, IntoId, PublicKey07, Source, - SourceProperty, ToAsString, ToAsUri, + sign, ActivityStream, ApSignature, CustomGroup, Id, IntoId, PublicKey, Source, SourceProperty, + ToAsString, ToAsUri, }; use webfinger::*; @@ -209,12 +209,12 @@ impl Blog { blog.set_id(self.ap_url.parse()?); - let pub_key = PublicKey07 { + let pub_key = PublicKey { id: format!("{}#main-key", self.ap_url).parse()?, owner: self.ap_url.parse()?, public_key_pem: self.public_key.clone(), }; - let ap_signature = ApSignature07 { + let ap_signature = ApSignature { public_key: pub_key, }; diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 0677a09a..ef32dfe1 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -28,7 +28,7 @@ use plume_common::{ inbox::{AsActor, AsObject, FromId}, request::get, sign::{gen_keypair, Error as SignError, Result as SignResult, Signer}, - ActivityStream, ApSignature07, CustomPerson, Id, IntoId, PublicKey07, ToAsString, ToAsUri, + ActivityStream, ApSignature, CustomPerson, Id, IntoId, PublicKey, ToAsString, ToAsUri, PUBLIC_VISIBILITY, }, utils, @@ -247,7 +247,7 @@ impl User { let mut res = get(url, Self::get_sender07(), CONFIG.proxy().cloned())?; let text = &res.text()?; // without this workaround, publicKey is not correctly deserialized - let ap_sign = serde_json::from_str::(text)?; + let ap_sign = serde_json::from_str::(text)?; let person = serde_json::from_str::(text)?; let json = CustomPerson::new( ApActor::new( @@ -795,12 +795,12 @@ impl User { actor.set_endpoints(endpoints); } - let pub_key = PublicKey07 { + let pub_key = PublicKey { id: format!("{}#main-key", self.ap_url).parse()?, owner: ap_url, public_key_pem: self.public_key.clone(), }; - let ap_signature = ApSignature07 { + let ap_signature = ApSignature { public_key: pub_key, };