mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-10 10:08:58 +00:00
Merge pull request 'Make apub extension fields optional (ref #1220)' (#163) from optional-apub-extensions into main
Reviewed-on: https://yerbamate.ml/LemmyNet/lemmy/pulls/163
This commit is contained in:
commit
def8af7d8a
|
@ -11,8 +11,8 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct GroupExtension {
|
||||
pub category: GroupCategory,
|
||||
pub sensitive: bool,
|
||||
pub category: Option<GroupCategory>,
|
||||
pub sensitive: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
|
@ -35,8 +35,8 @@ impl GroupExtension {
|
|||
name: category.name,
|
||||
};
|
||||
Ok(GroupExtension {
|
||||
category: group_category,
|
||||
sensitive,
|
||||
category: Some(group_category),
|
||||
sensitive: Some(sensitive),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct PageExtension {
|
||||
pub comments_enabled: bool,
|
||||
pub sensitive: bool,
|
||||
pub stickied: bool,
|
||||
pub comments_enabled: Option<bool>,
|
||||
pub sensitive: Option<bool>,
|
||||
pub stickied: Option<bool>,
|
||||
}
|
||||
|
||||
impl<U> UnparsedExtension<U> for PageExtension
|
||||
|
|
|
@ -207,13 +207,19 @@ impl FromApubToForm<GroupExt> for CommunityForm {
|
|||
name,
|
||||
title,
|
||||
description,
|
||||
category_id: group.ext_one.category.identifier.parse::<i32>()?,
|
||||
category_id: group
|
||||
.ext_one
|
||||
.category
|
||||
.clone()
|
||||
.map(|c| c.identifier.parse::<i32>().ok())
|
||||
.flatten()
|
||||
.unwrap_or(1),
|
||||
creator_id: creator.id,
|
||||
removed: None,
|
||||
published: group.inner.published().map(|u| u.to_owned().naive_local()),
|
||||
updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
|
||||
deleted: None,
|
||||
nsfw: group.ext_one.sensitive,
|
||||
nsfw: group.ext_one.sensitive.unwrap_or(false),
|
||||
actor_id: Some(check_object_domain(group, expected_domain)?),
|
||||
local: false,
|
||||
private_key: None,
|
||||
|
|
|
@ -85,9 +85,9 @@ impl ToApub for Post {
|
|||
}
|
||||
|
||||
let ext = PageExtension {
|
||||
comments_enabled: !self.locked,
|
||||
sensitive: self.nsfw,
|
||||
stickied: self.stickied,
|
||||
comments_enabled: Some(!self.locked),
|
||||
sensitive: Some(self.nsfw),
|
||||
stickied: Some(self.stickied),
|
||||
};
|
||||
Ok(Ext1::new(page, ext))
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ impl FromApubToForm<PageExt> for PostForm {
|
|||
creator_id: creator.id,
|
||||
community_id: community.id,
|
||||
removed: None,
|
||||
locked: Some(!ext.comments_enabled),
|
||||
locked: ext.comments_enabled.map(|e| !e),
|
||||
published: page
|
||||
.inner
|
||||
.published()
|
||||
|
@ -210,8 +210,8 @@ impl FromApubToForm<PageExt> for PostForm {
|
|||
.as_ref()
|
||||
.map(|u| u.to_owned().naive_local()),
|
||||
deleted: None,
|
||||
nsfw: ext.sensitive,
|
||||
stickied: Some(ext.stickied),
|
||||
nsfw: ext.sensitive.unwrap_or(false),
|
||||
stickied: ext.stickied.or(Some(false)),
|
||||
embed_title: iframely_title,
|
||||
embed_description: iframely_description,
|
||||
embed_html: iframely_html,
|
||||
|
|
Loading…
Reference in a new issue