]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/objects/community.rs
Making public key required. Fixes #1934
[lemmy.git] / crates / apub / src / objects / community.rs
index f2fb45e4fb30899ce18684341b78c5cc9e050737..300ad2f2c093cfdfb7be2222404ca1a6ffe38777 100644 (file)
@@ -9,7 +9,7 @@ use crate::{
     Source,
   },
 };
-use activitystreams::{actor::kind::GroupType, object::kind::ImageType};
+use activitystreams_kinds::actor::GroupType;
 use chrono::NaiveDateTime;
 use itertools::Itertools;
 use lemmy_api_common::blocking;
@@ -81,14 +81,8 @@ impl ApubObject for ApubCommunity {
       content: bio,
       media_type: MediaTypeMarkdown::Markdown,
     });
-    let icon = self.icon.clone().map(|url| ImageObject {
-      kind: ImageType::Image,
-      url: url.into(),
-    });
-    let image = self.banner.clone().map(|url| ImageObject {
-      kind: ImageType::Image,
-      url: url.into(),
-    });
+    let icon = self.icon.clone().map(ImageObject::new);
+    let image = self.banner.clone().map(ImageObject::new);
 
     let group = Group {
       kind: GroupType::Group,
@@ -118,10 +112,7 @@ impl ApubObject for ApubCommunity {
   }
 
   fn to_tombstone(&self) -> Result<Tombstone, LemmyError> {
-    Ok(Tombstone::new(
-      GroupType::Group,
-      self.updated.unwrap_or(self.published),
-    ))
+    Ok(Tombstone::new(self.actor_id()))
   }
 
   async fn verify(
@@ -172,7 +163,7 @@ impl ActorType for ApubCommunity {
   fn actor_id(&self) -> Url {
     self.actor_id.to_owned().into()
   }
-  fn public_key(&self) -> Option<String> {
+  fn public_key(&self) -> String {
     self.public_key.to_owned()
   }
   fn private_key(&self) -> Option<String> {
@@ -192,7 +183,6 @@ impl ApubCommunity {
   /// For a given community, returns the inboxes of all followers.
   pub(crate) async fn get_follower_inboxes(
     &self,
-    additional_inboxes: Vec<Url>,
     context: &LemmyContext,
   ) -> Result<Vec<Url>, LemmyError> {
     let id = self.id;
@@ -201,7 +191,7 @@ impl ApubCommunity {
       CommunityFollowerView::for_community(conn, id)
     })
     .await??;
-    let follower_inboxes: Vec<Url> = follows
+    let inboxes: Vec<Url> = follows
       .into_iter()
       .filter(|f| !f.follower.local)
       .map(|f| {
@@ -210,12 +200,8 @@ impl ApubCommunity {
           .unwrap_or(f.follower.inbox_url)
           .into()
       })
-      .collect();
-    let inboxes = vec![follower_inboxes, additional_inboxes]
-      .into_iter()
-      .flatten()
       .unique()
-      .filter(|inbox| inbox.host_str() != Some(&context.settings().hostname))
+      .filter(|inbox: &Url| inbox.host_str() != Some(&context.settings().hostname))
       // Don't send to blocked instances
       .filter(|inbox| check_is_apub_id_valid(inbox, false, &context.settings()).is_ok())
       .collect();
@@ -258,7 +244,6 @@ pub(crate) mod tests {
     let community = parse_lemmy_community(&context).await;
 
     assert_eq!(community.title, "Ten Forward");
-    assert!(community.public_key.is_some());
     assert!(!community.local);
     assert_eq!(community.description.as_ref().unwrap().len(), 132);