]> Untitled Git - lemmy.git/blobdiff - lemmy_apub/src/objects/community.rs
Merge branch 'main' into move_views_to_diesel
[lemmy.git] / lemmy_apub / src / objects / community.rs
index 91638ef02e34275e1b21e81f2ac1b12c67b584e6..8cc5b9eb5cb231574d4e1ca40d13d5e329c8aaeb 100644 (file)
@@ -4,13 +4,15 @@ use crate::{
   objects::{
     check_object_domain,
     create_tombstone,
+    get_object_from_apub,
     get_source_markdown_value,
     set_content_and_source,
+    FromApub,
+    FromApubToForm,
+    ToApub,
   },
   ActorType,
-  FromApub,
   GroupExt,
-  ToApub,
 };
 use activitystreams::{
   actor::{kind::GroupType, ApActor, Endpoints, Group},
@@ -109,14 +111,28 @@ impl ToApub for Community {
     create_tombstone(self.deleted, &self.actor_id, self.updated, GroupType::Group)
   }
 }
+
 #[async_trait::async_trait(?Send)]
-impl FromApub for CommunityForm {
+impl FromApub for Community {
   type ApubType = GroupExt;
 
+  /// Converts a `Group` to `Community`.
+  async fn from_apub(
+    group: &GroupExt,
+    context: &LemmyContext,
+    expected_domain: Url,
+    request_counter: &mut i32,
+  ) -> Result<Community, LemmyError> {
+    get_object_from_apub(group, context, expected_domain, request_counter).await
+  }
+}
+
+#[async_trait::async_trait(?Send)]
+impl FromApubToForm<GroupExt> for CommunityForm {
   async fn from_apub(
     group: &GroupExt,
     context: &LemmyContext,
-    expected_domain: Option<Url>,
+    expected_domain: Url,
     request_counter: &mut i32,
   ) -> Result<Self, LemmyError> {
     let creator_and_moderator_uris = group.inner.attributed_to().context(location_info!())?;