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)]
#[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<U> UnparsedExtension<U> for ApSignature07
impl<U> UnparsedExtension<U> for ApSignature
where
U: UnparsedMutExt,
{
type Error = serde_json::Error;
fn try_from_unparsed(unparsed_mut: &mut U) -> Result<Self, Self::Error> {
Ok(ApSignature07 {
Ok(ApSignature {
public_key: unparsed_mut.remove("publicKey")?,
})
}
@ -349,8 +349,8 @@ where
}
}
pub type CustomPerson = Ext1<ApActor<Person>, ApSignature07>;
pub type CustomGroup = Ext2<ApActor<Group>, ApSignature07, SourceProperty>;
pub type CustomPerson = Ext1<ApActor<Person>, ApSignature>;
pub type CustomGroup = Ext2<ApActor<Group>, 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(),

View File

@ -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,
};

View File

@ -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::<ApSignature07>(text)?;
let ap_sign = serde_json::from_str::<ApSignature>(text)?;
let person = serde_json::from_str::<Person>(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,
};