]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/protocol/mod.rs
Use audience field to federate items in groups (fixes #2464) (#2584)
[lemmy.git] / crates / apub / src / protocol / mod.rs
index c259a6e996bd13f26579c0cfd84336e9c283a088..a65e74da225a1d77b6b63956fc321bcf0f65839f 100644 (file)
@@ -1,4 +1,4 @@
-use crate::local_instance;
+use crate::{local_instance, objects::community::ApubCommunity};
 use activitypub_federation::{deser::values::MediaTypeMarkdown, utils::fetch_object_http};
 use activitystreams_kinds::object::ImageType;
 use lemmy_db_schema::newtypes::DbUrl;
@@ -81,6 +81,17 @@ impl<Kind: Id + DeserializeOwned> IdOrNestedObject<Kind> {
   }
 }
 
+#[async_trait::async_trait(?Send)]
+pub trait InCommunity {
+  // TODO: after we use audience field and remove backwards compat, it should be possible to change
+  //       this to simply `fn community(&self)  -> Result<ObjectId<ApubCommunity>, LemmyError>`
+  async fn community(
+    &self,
+    context: &LemmyContext,
+    request_counter: &mut i32,
+  ) -> Result<ApubCommunity, LemmyError>;
+}
+
 #[cfg(test)]
 pub(crate) mod tests {
   use activitypub_federation::deser::context::WithContext;