summaryrefslogtreecommitdiffstats
path: root/server/src/apub/community.rs
diff options
context:
space:
mode:
authorFelix <me@nutomic.com>2020-05-05 16:30:13 +0200
committerFelix <me@nutomic.com>2020-05-05 16:30:13 +0200
commitdfd6629a6fc1fa43abf2815e9b219c3c0e832072 (patch)
tree3fc3a0cd2a11cd6fa4be05b1b022a9ec816788d6 /server/src/apub/community.rs
parent21407260a4bfc3c173d4f17b6540805fe60f3519 (diff)
Federate community category and nsfw
Diffstat (limited to 'server/src/apub/community.rs')
-rw-r--r--server/src/apub/community.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs
index feffa70e..f7cd213d 100644
--- a/server/src/apub/community.rs
+++ b/server/src/apub/community.rs
@@ -51,7 +51,14 @@ impl ToApub for Community {
.set_endpoints(endpoint_props)?
.set_followers(self.get_followers_url())?;
- Ok(group.extend(actor_props).extend(self.get_public_key_ext()))
+ let group_extension = GroupExtension::new(conn, self.category_id, self.nsfw)?;
+
+ Ok(
+ group
+ .extend(group_extension)
+ .extend(actor_props)
+ .extend(self.get_public_key_ext()),
+ )
}
fn to_tombstone(&self) -> Result<Tombstone, Error> {
@@ -304,7 +311,8 @@ impl FromApub for CommunityForm {
/// Parse an ActivityPub group received from another instance into a Lemmy community.
fn from_apub(group: &GroupExt, conn: &PgConnection) -> Result<Self, Error> {
- let oprops = &group.base.base.object_props;
+ let group_extensions: &GroupExtension = &group.base.base.extension;
+ let oprops = &group.base.base.base.object_props;
let aprops = &group.base.extension;
let public_key: &PublicKey = &group.extension.public_key;
@@ -325,7 +333,7 @@ impl FromApub for CommunityForm {
// TODO: should be parsed as html and tags like <script> removed (or use markdown source)
// -> same for post.content etc
description: oprops.get_content_xsd_string().map(|s| s.to_string()),
- category_id: 1, // -> peertube uses `"category": {"identifier": "9","name": "Comedy"},`
+ category_id: group_extensions.category.identifier.parse::<i32>()?,
creator_id: creator.id,
removed: None,
published: oprops
@@ -335,7 +343,7 @@ impl FromApub for CommunityForm {
.get_updated()
.map(|u| u.as_ref().to_owned().naive_local()),
deleted: None,
- nsfw: false,
+ nsfw: group_extensions.sensitive,
actor_id: oprops.get_id().unwrap().to_string(),
local: false,
private_key: None,