activities::send::generate_activity_id,
activity_queue::{send_activity_single_dest, send_to_community_followers},
check_is_apub_id_valid,
- fetcher::get_or_fetch_and_upsert_actor,
+ fetcher::get_or_fetch_and_upsert_user,
ActorType,
ToApub,
};
.actor()?
.as_single_xsd_any_uri()
.context(location_info!())?;
- let actor = get_or_fetch_and_upsert_actor(actor_uri, context).await?;
+ let user = get_or_fetch_and_upsert_user(actor_uri, context).await?;
let mut accept = Accept::new(self.actor_id.to_owned(), follow.into_any_base()?);
- let to = actor.get_inbox_url()?;
accept
.set_context(activitystreams::context())
.set_id(generate_activity_id(AcceptType::Accept)?)
- .set_to(to.clone());
+ .set_to(user.actor_id()?);
- send_activity_single_dest(accept, self, to, context).await?;
+ send_activity_single_dest(accept, self, user.get_inbox_url()?, context).await?;
Ok(())
}
use crate::{
activities::send::generate_activity_id,
activity_queue::send_activity_single_dest,
- fetcher::get_or_fetch_and_upsert_actor,
ActorType,
};
use activitystreams::{
Undo,
},
base::{AnyBase, BaseExt, ExtendsExt},
+ object::ObjectExt,
};
-use lemmy_db::{user::User_, DbPool};
+use lemmy_db::{community::Community, user::User_, DbPool};
+use lemmy_structs::blocking;
use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext;
use url::Url;
follow_actor_id: &Url,
context: &LemmyContext,
) -> Result<(), LemmyError> {
- let mut follow = Follow::new(self.actor_id.to_owned(), follow_actor_id.as_str());
+ let follow_actor_id = follow_actor_id.to_string();
+ let community = blocking(context.pool(), move |conn| {
+ Community::read_from_actor_id(conn, &follow_actor_id)
+ })
+ .await??;
+
+ let mut follow = Follow::new(self.actor_id.to_owned(), community.actor_id()?);
follow
.set_context(activitystreams::context())
- .set_id(generate_activity_id(FollowType::Follow)?);
- let follow_actor = get_or_fetch_and_upsert_actor(follow_actor_id, context).await?;
- let to = follow_actor.get_inbox_url()?;
+ .set_id(generate_activity_id(FollowType::Follow)?)
+ .set_to(community.actor_id()?);
- send_activity_single_dest(follow, self, to, context).await?;
+ send_activity_single_dest(follow, self, community.get_inbox_url()?, context).await?;
Ok(())
}
follow_actor_id: &Url,
context: &LemmyContext,
) -> Result<(), LemmyError> {
- let mut follow = Follow::new(self.actor_id.to_owned(), follow_actor_id.as_str());
+ let follow_actor_id = follow_actor_id.to_string();
+ let community = blocking(context.pool(), move |conn| {
+ Community::read_from_actor_id(conn, &follow_actor_id)
+ })
+ .await??;
+
+ let mut follow = Follow::new(self.actor_id.to_owned(), community.actor_id()?);
follow
.set_context(activitystreams::context())
- .set_id(generate_activity_id(FollowType::Follow)?);
- let follow_actor = get_or_fetch_and_upsert_actor(follow_actor_id, context).await?;
-
- let to = follow_actor.get_inbox_url()?;
+ .set_id(generate_activity_id(FollowType::Follow)?)
+ .set_to(community.actor_id()?);
// Undo that fake activity
let mut undo = Undo::new(Url::parse(&self.actor_id)?, follow.into_any_base()?);
undo
.set_context(activitystreams::context())
- .set_id(generate_activity_id(UndoType::Undo)?);
+ .set_id(generate_activity_id(UndoType::Undo)?)
+ .set_to(community.actor_id()?);
- send_activity_single_dest(undo, self, to, context).await?;
+ send_activity_single_dest(undo, self, community.get_inbox_url()?, context).await?;
Ok(())
}