]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/activities/send/community.rs
Rewrite activitypub following, person, community, pm (#1692)
[lemmy.git] / crates / apub / src / activities / send / community.rs
index 852410624cfbd0028b0bc781adcfe5cfc49571c4..6f88dd36fb76848c559de8ff8853d845073c60ba 100644 (file)
@@ -1,9 +1,9 @@
 use crate::{
   activities::generate_activity_id,
-  activity_queue::{send_activity_single_dest, send_to_community, send_to_community_followers},
+  activity_queue::{send_to_community, send_to_community_followers},
   check_is_apub_id_valid,
   extensions::context::lemmy_context,
-  fetcher::{get_or_fetch_and_upsert_actor, person::get_or_fetch_and_upsert_person},
+  fetcher::get_or_fetch_and_upsert_actor,
   generate_moderators_url,
   insert_activity,
   objects::ToApub,
@@ -13,7 +13,6 @@ use crate::{
 use activitystreams::{
   activity::{
     kind::{
-      AcceptType,
       AddType,
       AnnounceType,
       BlockType,
@@ -23,13 +22,10 @@ use activitystreams::{
       UndoType,
       UpdateType,
     },
-    Accept,
-    ActorAndObjectRefExt,
     Add,
     Announce,
     Block,
     Delete,
-    Follow,
     OptTargetRefExt,
     Remove,
     Undo,
@@ -81,31 +77,6 @@ impl CommunityType for Community {
     self.followers_url.clone().into()
   }
 
-  /// As a local community, accept the follow request from a remote person.
-  async fn send_accept_follow(
-    &self,
-    follow: Follow,
-    context: &LemmyContext,
-  ) -> Result<(), LemmyError> {
-    let actor_uri = follow
-      .actor()?
-      .as_single_xsd_any_uri()
-      .context(location_info!())?;
-    let person = get_or_fetch_and_upsert_person(actor_uri, context, &mut 0).await?;
-
-    let mut accept = Accept::new(
-      self.actor_id.to_owned().into_inner(),
-      follow.into_any_base()?,
-    );
-    accept
-      .set_many_contexts(lemmy_context())
-      .set_id(generate_activity_id(AcceptType::Accept)?)
-      .set_to(person.actor_id());
-
-    send_activity_single_dest(accept, self, person.inbox_url.into(), context).await?;
-    Ok(())
-  }
-
   /// If a remote community is updated by a local mod, send the updated info to the community's
   /// instance.
   async fn send_update(&self, mod_: Person, context: &LemmyContext) -> Result<(), LemmyError> {
@@ -114,7 +85,7 @@ impl CommunityType for Community {
     } else {
       let mut update = Update::new(
         mod_.actor_id(),
-        self.to_apub(context.pool()).await?.into_any_base()?,
+        AnyBase::from_arbitrary_json(self.to_apub(context.pool()).await?)?,
       );
       update
         .set_many_contexts(lemmy_context())