]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/objects/community.rs
Diesel 2.0.0 upgrade (#2452)
[lemmy.git] / crates / apub / src / objects / community.rs
index 4c381c1c44387c83922ca91211baa8cbd88e2e09..cf2dab94eb48c4d33cb92efe3a6c79cc20417f42 100644 (file)
@@ -13,8 +13,8 @@ use crate::{
   ActorType,
 };
 use activitypub_federation::{
-  core::{inbox::ActorPublicKey, object_id::ObjectId},
-  traits::ApubObject,
+  core::object_id::ObjectId,
+  traits::{Actor, ApubObject},
 };
 use activitystreams_kinds::actor::GroupType;
 use chrono::NaiveDateTime;
@@ -139,14 +139,14 @@ impl ApubObject for ApubCommunity {
 
     group
       .outbox
-      .dereference::<LemmyError>(&outbox_data, local_instance(context), request_counter)
+      .dereference(&outbox_data, local_instance(context), request_counter)
       .await
       .map_err(|e| debug!("{}", e))
       .ok();
 
     if let Some(moderators) = &group.moderators {
       moderators
-        .dereference::<LemmyError>(&outbox_data, local_instance(context), request_counter)
+        .dereference(&outbox_data, local_instance(context), request_counter)
         .await
         .map_err(|e| debug!("{}", e))
         .ok();
@@ -158,26 +158,26 @@ impl ApubObject for ApubCommunity {
   }
 }
 
-impl ActorType for ApubCommunity {
-  fn actor_id(&self) -> Url {
-    self.actor_id.to_owned().into()
-  }
-  fn private_key(&self) -> Option<String> {
-    self.private_key.to_owned()
+impl Actor for ApubCommunity {
+  fn public_key(&self) -> &str {
+    &self.public_key
   }
 
-  fn inbox_url(&self) -> Url {
+  fn inbox(&self) -> Url {
     self.inbox_url.clone().into()
   }
 
-  fn shared_inbox_url(&self) -> Option<Url> {
+  fn shared_inbox(&self) -> Option<Url> {
     self.shared_inbox_url.clone().map(|s| s.into())
   }
 }
 
-impl ActorPublicKey for ApubCommunity {
-  fn public_key(&self) -> &str {
-    &self.public_key
+impl ActorType for ApubCommunity {
+  fn actor_id(&self) -> Url {
+    self.actor_id.to_owned().into()
+  }
+  fn private_key(&self) -> Option<String> {
+    self.private_key.to_owned()
   }
 }
 
@@ -206,9 +206,7 @@ impl ApubCommunity {
       .unique()
       .filter(|inbox: &Url| inbox.host_str() != Some(&context.settings().hostname))
       // Don't send to blocked instances
-      .filter(|inbox| {
-        check_apub_id_valid_with_strictness(inbox, false, &context.settings()).is_ok()
-      })
+      .filter(|inbox| check_apub_id_valid_with_strictness(inbox, false, context.settings()).is_ok())
       .collect();
 
     Ok(inboxes)
@@ -249,6 +247,7 @@ pub(crate) mod tests {
   #[serial]
   async fn test_parse_lemmy_community() {
     let context = init_context();
+    let conn = &mut context.pool().get().unwrap();
     let site = parse_lemmy_instance(&context).await;
     let community = parse_lemmy_community(&context).await;
 
@@ -256,7 +255,7 @@ pub(crate) mod tests {
     assert!(!community.local);
     assert_eq!(community.description.as_ref().unwrap().len(), 132);
 
-    Community::delete(&*context.pool().get().unwrap(), community.id).unwrap();
-    Site::delete(&*context.pool().get().unwrap(), site.id).unwrap();
+    Community::delete(conn, community.id).unwrap();
+    Site::delete(conn, site.id).unwrap();
   }
 }