]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/collections/community_moderators.rs
Implement instance actor (#1798)
[lemmy.git] / crates / apub / src / collections / community_moderators.rs
index 9b8d26d9f1ff7286a4de19a0eddb61ea899313e0..72d23d4acd5287d23a0d7e65ec5e0fbb87512987 100644 (file)
@@ -29,6 +29,7 @@ impl ApubObject for ApubCommunityModerators {
     None
   }
 
+  #[tracing::instrument(skip_all)]
   async fn read_from_apub_id(
     _object_id: Url,
     data: &Self::DataType,
@@ -46,10 +47,12 @@ impl ApubObject for ApubCommunityModerators {
     }
   }
 
+  #[tracing::instrument(skip_all)]
   async fn delete(self, _data: &Self::DataType) -> Result<(), LemmyError> {
     unimplemented!()
   }
 
+  #[tracing::instrument(skip_all)]
   async fn into_apub(self, data: &Self::DataType) -> Result<Self::ApubType, LemmyError> {
     let ordered_items = self
       .0
@@ -67,6 +70,7 @@ impl ApubObject for ApubCommunityModerators {
     unimplemented!()
   }
 
+  #[tracing::instrument(skip_all)]
   async fn verify(
     group_moderators: &GroupModerators,
     expected_domain: &Url,
@@ -77,6 +81,7 @@ impl ApubObject for ApubCommunityModerators {
     Ok(())
   }
 
+  #[tracing::instrument(skip_all)]
   async fn from_apub(
     apub: Self::ApubType,
     data: &Self::DataType,
@@ -105,7 +110,9 @@ impl ApubObject for ApubCommunityModerators {
     // Add new mods to database which have been added to moderators collection
     for mod_id in apub.ordered_items {
       let mod_id = ObjectId::new(mod_id);
-      let mod_user: ApubPerson = mod_id.dereference(&data.1, request_counter).await?;
+      let mod_user: ApubPerson = mod_id
+        .dereference(&data.1, data.1.client(), request_counter)
+        .await?;
 
       if !current_moderators
         .iter()
@@ -141,6 +148,7 @@ mod tests {
     source::{
       community::Community,
       person::{Person, PersonForm},
+      site::Site,
     },
     traits::Crud,
   };
@@ -149,8 +157,10 @@ mod tests {
   #[actix_rt::test]
   #[serial]
   async fn test_parse_lemmy_community_moderators() {
-    let manager = create_activity_queue();
+    let client = reqwest::Client::new().into();
+    let manager = create_activity_queue(client);
     let context = init_context(manager.queue_handle().clone());
+    let (new_mod, site) = parse_lemmy_person(&context).await;
     let community = parse_lemmy_community(&context).await;
     let community_id = community.id;
 
@@ -166,10 +176,10 @@ mod tests {
 
     CommunityModerator::join(&context.pool().get().unwrap(), &community_moderator_form).unwrap();
 
-    let new_mod = parse_lemmy_person(&context).await;
+    assert_eq!(site.actor_id.to_string(), "https://enterprise.lemmy.ml/");
 
     let json: GroupModerators =
-      file_to_json_object("assets/lemmy/collections/group_moderators.json");
+      file_to_json_object("assets/lemmy/collections/group_moderators.json").unwrap();
     let url = Url::parse("https://enterprise.lemmy.ml/c/tenforward").unwrap();
     let mut request_counter = 0;
     let community_context = CommunityContext {
@@ -201,5 +211,6 @@ mod tests {
       community_context.0.id,
     )
     .unwrap();
+    Site::delete(&*community_context.1.pool().get().unwrap(), site.id).unwrap();
   }
 }