From 41bc2d6949632a11bd9492fba7c7c537f6863242 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 1 May 2022 18:53:51 +0900 Subject: [PATCH] Make LicensedArticle's license fieald optional --- plume-common/src/activity_pub/mod.rs | 2 +- plume-models/src/inbox.rs | 2 +- plume-models/src/posts.rs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index 3462d564..9ba7bfe0 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -558,7 +558,7 @@ impl Object for Licensed {} #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct Licensed07 { - pub license: String, + pub license: Option, } impl UnparsedExtension for Licensed07 diff --git a/plume-models/src/inbox.rs b/plume-models/src/inbox.rs index d1a318fe..89683615 100644 --- a/plume-models/src/inbox.rs +++ b/plume-models/src/inbox.rs @@ -63,7 +63,7 @@ pub fn inbox(conn: &DbConn, act: serde_json::Value) -> Result(CONFIG.proxy()) .with07::(CONFIG.proxy()) .with07::(CONFIG.proxy()) - .with::(CONFIG.proxy()) + .with07::(CONFIG.proxy()) .done() } diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index a2ad8e0d..7a1930eb 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -492,7 +492,7 @@ impl Post { .collect::>(), ); let license = Licensed07 { - license: self.license.clone(), + license: Some(self.license.clone()), }; Ok(LicensedArticle07::new(article, license, source)) } @@ -1026,7 +1026,7 @@ impl FromId07 for Post { } fn from_activity07(conn: &DbConn, article: LicensedArticle07) -> Result { - let license = article.ext_one.license; + let license = article.ext_one.license.unwrap_or_default(); let source = article.ext_two.source.content; let article = article.inner; @@ -1357,7 +1357,7 @@ impl FromId07 for PostUpdate { .and_then(|m| m.map(|m| m.id)) }); post_update.source = Some(updated.ext_two.source.content); - post_update.license = Some(updated.ext_one.license); + post_update.license = updated.ext_one.license; Ok(post_update) }