Rename: ApSignature07 -> ApSignature

This commit is contained in:
Kitaiti Makoto 2022-05-03 00:29:44 +09:00
parent 992a482b96
commit e4180b3b38
3 changed files with 22 additions and 22 deletions

View file

@ -295,26 +295,26 @@ impl Link for Id {}
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct ApSignature07 { pub struct ApSignature {
pub public_key: PublicKey07, pub public_key: PublicKey,
} }
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct PublicKey07 { pub struct PublicKey {
pub id: IriString, pub id: IriString,
pub owner: IriString, pub owner: IriString,
pub public_key_pem: String, pub public_key_pem: String,
} }
impl<U> UnparsedExtension<U> for ApSignature07 impl<U> UnparsedExtension<U> for ApSignature
where where
U: UnparsedMutExt, U: UnparsedMutExt,
{ {
type Error = serde_json::Error; type Error = serde_json::Error;
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> { fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
Ok(ApSignature07 { Ok(ApSignature {
public_key: unparsed_mut.remove("publicKey")?, public_key: unparsed_mut.remove("publicKey")?,
}) })
} }
@ -349,8 +349,8 @@ where
} }
} }
pub type CustomPerson = Ext1<ApActor<Person>, ApSignature07>; pub type CustomPerson = Ext1<ApActor<Person>, ApSignature>;
pub type CustomGroup = Ext2<ApActor<Group>, ApSignature07, SourceProperty>; pub type CustomGroup = Ext2<ApActor<Group>, ApSignature, SourceProperty>;
kind!(HashtagType, Hashtag); kind!(HashtagType, Hashtag);
@ -584,8 +584,8 @@ mod tests {
#[test] #[test]
fn se_ap_signature() { fn se_ap_signature() {
let ap_signature = ApSignature07 { let ap_signature = ApSignature {
public_key: PublicKey07 { public_key: PublicKey {
id: "https://example.com/pubkey".parse().unwrap(), id: "https://example.com/pubkey".parse().unwrap(),
owner: "https://example.com/owner".parse().unwrap(), owner: "https://example.com/owner".parse().unwrap(),
public_key_pem: "pubKeyPem".into(), public_key_pem: "pubKeyPem".into(),
@ -603,7 +603,7 @@ mod tests {
#[test] #[test]
fn de_ap_signature() { fn de_ap_signature() {
let value: ApSignature07 = from_str( let value: ApSignature = from_str(
r#" r#"
{ {
"publicKey": { "publicKey": {
@ -615,8 +615,8 @@ mod tests {
"#, "#,
) )
.unwrap(); .unwrap();
let expected = ApSignature07 { let expected = ApSignature {
public_key: PublicKey07 { public_key: PublicKey {
id: "https://example.com/".parse().unwrap(), id: "https://example.com/".parse().unwrap(),
owner: "https://example.com/".parse().unwrap(), owner: "https://example.com/".parse().unwrap(),
public_key_pem: "".into(), public_key_pem: "".into(),
@ -630,8 +630,8 @@ mod tests {
let actor = ApActor::new("https://example.com/inbox".parse().unwrap(), Person::new()); let actor = ApActor::new("https://example.com/inbox".parse().unwrap(), Person::new());
let person = CustomPerson::new( let person = CustomPerson::new(
actor, actor,
ApSignature07 { ApSignature {
public_key: PublicKey07 { public_key: PublicKey {
id: "https://example.com/pubkey".parse().unwrap(), id: "https://example.com/pubkey".parse().unwrap(),
owner: "https://example.com/owner".parse().unwrap(), owner: "https://example.com/owner".parse().unwrap(),
public_key_pem: "pubKeyPem".into(), public_key_pem: "pubKeyPem".into(),

View file

@ -20,8 +20,8 @@ use openssl::{
}; };
use plume_common::activity_pub::{ use plume_common::activity_pub::{
inbox::{AsActor, FromId}, inbox::{AsActor, FromId},
sign, ActivityStream, ApSignature07, CustomGroup, Id, IntoId, PublicKey07, Source, sign, ActivityStream, ApSignature, CustomGroup, Id, IntoId, PublicKey, Source, SourceProperty,
SourceProperty, ToAsString, ToAsUri, ToAsString, ToAsUri,
}; };
use webfinger::*; use webfinger::*;
@ -209,12 +209,12 @@ impl Blog {
blog.set_id(self.ap_url.parse()?); blog.set_id(self.ap_url.parse()?);
let pub_key = PublicKey07 { let pub_key = PublicKey {
id: format!("{}#main-key", self.ap_url).parse()?, id: format!("{}#main-key", self.ap_url).parse()?,
owner: self.ap_url.parse()?, owner: self.ap_url.parse()?,
public_key_pem: self.public_key.clone(), public_key_pem: self.public_key.clone(),
}; };
let ap_signature = ApSignature07 { let ap_signature = ApSignature {
public_key: pub_key, public_key: pub_key,
}; };

View file

@ -28,7 +28,7 @@ use plume_common::{
inbox::{AsActor, AsObject, FromId}, inbox::{AsActor, AsObject, FromId},
request::get, request::get,
sign::{gen_keypair, Error as SignError, Result as SignResult, Signer}, 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, PUBLIC_VISIBILITY,
}, },
utils, utils,
@ -247,7 +247,7 @@ impl User {
let mut res = get(url, Self::get_sender07(), CONFIG.proxy().cloned())?; let mut res = get(url, Self::get_sender07(), CONFIG.proxy().cloned())?;
let text = &res.text()?; let text = &res.text()?;
// without this workaround, publicKey is not correctly deserialized // without this workaround, publicKey is not correctly deserialized
let ap_sign = serde_json::from_str::<ApSignature07>(text)?; let ap_sign = serde_json::from_str::<ApSignature>(text)?;
let person = serde_json::from_str::<Person>(text)?; let person = serde_json::from_str::<Person>(text)?;
let json = CustomPerson::new( let json = CustomPerson::new(
ApActor::new( ApActor::new(
@ -795,12 +795,12 @@ impl User {
actor.set_endpoints(endpoints); actor.set_endpoints(endpoints);
} }
let pub_key = PublicKey07 { let pub_key = PublicKey {
id: format!("{}#main-key", self.ap_url).parse()?, id: format!("{}#main-key", self.ap_url).parse()?,
owner: ap_url, owner: ap_url,
public_key_pem: self.public_key.clone(), public_key_pem: self.public_key.clone(),
}; };
let ap_signature = ApSignature07 { let ap_signature = ApSignature {
public_key: pub_key, public_key: pub_key,
}; };