Make LicensedArticle's license fieald optional

This commit is contained in:
Kitaiti Makoto 2022-05-01 18:53:51 +09:00
parent de6e9c0e2e
commit 41bc2d6949
3 changed files with 5 additions and 5 deletions

View File

@ -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<String>,
}
impl<U> UnparsedExtension<U> for Licensed07

View File

@ -63,7 +63,7 @@ pub fn inbox(conn: &DbConn, act: serde_json::Value) -> Result<InboxResult, Error
.with07::<User, Undo07, Reshare>(CONFIG.proxy())
.with07::<User, Undo07, follows::Follow>(CONFIG.proxy())
.with07::<User, Undo07, likes::Like>(CONFIG.proxy())
.with::<User, Update, PostUpdate>(CONFIG.proxy())
.with07::<User, Update07, PostUpdate>(CONFIG.proxy())
.done()
}

View File

@ -492,7 +492,7 @@ impl Post {
.collect::<Vec<IriString>>(),
);
let license = Licensed07 {
license: self.license.clone(),
license: Some(self.license.clone()),
};
Ok(LicensedArticle07::new(article, license, source))
}
@ -1026,7 +1026,7 @@ impl FromId07<DbConn> for Post {
}
fn from_activity07(conn: &DbConn, article: LicensedArticle07) -> Result<Self> {
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<DbConn> 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)
}