From efbbb2364c01d34e68654e2325012f0d0ce4e81c Mon Sep 17 00:00:00 2001 From: Felix Date: Tue, 5 May 2020 16:30:13 +0200 Subject: [PATCH] Federate community category and nsfw --- server/src/api/mod.rs | 2 +- server/src/apub/community.rs | 16 +++++-- .../src/apub/extensions/group_extensions.rs | 42 +++++++++++++++++++ server/src/apub/extensions/mod.rs | 3 ++ .../apub/{ => extensions}/page_extension.rs | 4 +- .../src/apub/{ => extensions}/signatures.rs | 13 +++++- server/src/apub/fetcher.rs | 3 +- server/src/apub/mod.rs | 23 ++++------ server/src/db/code_migrations.rs | 2 +- 9 files changed, 84 insertions(+), 24 deletions(-) create mode 100644 server/src/apub/extensions/group_extensions.rs create mode 100644 server/src/apub/extensions/mod.rs rename server/src/apub/{ => extensions}/page_extension.rs (69%) rename server/src/apub/{ => extensions}/signatures.rs (90%) diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index 8bc03feea..9112a3be3 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -23,8 +23,8 @@ use crate::{ }; use crate::apub::{ + extensions::signatures::generate_actor_keypair, fetcher::search_by_apub_id, - signatures::generate_actor_keypair, {make_apub_endpoint, ActorType, ApubLikeableType, ApubObjectType, EndpointType}, }; use crate::settings::Settings; diff --git a/server/src/apub/community.rs b/server/src/apub/community.rs index feffa70ef..f7cd213d3 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 { @@ -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 { - 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