-#[derive(Clone, Debug, Deserialize, Serialize, ActivityFields)]
-#[serde(rename_all = "camelCase")]
-pub struct AcceptFollowCommunity {
- actor: ObjectId<Community>,
- to: ObjectId<Person>,
- object: FollowCommunity,
- #[serde(rename = "type")]
- kind: AcceptType,
- id: Url,
- #[serde(rename = "@context")]
- context: OneOrMany<AnyBase>,
- #[serde(flatten)]
- unparsed: Unparsed,
-}
-
-impl AcceptFollowCommunity {
- pub async fn send(follow: FollowCommunity, context: &LemmyContext) -> Result<(), LemmyError> {
- let community_id = follow.object.clone();
- let community = blocking(context.pool(), move |conn| {
- Community::read_from_apub_id(conn, &community_id.into())
- })
- .await??;
- let person_id = follow.actor().clone();
- let person = blocking(context.pool(), move |conn| {
- Person::read_from_apub_id(conn, &person_id.into())
- })
- .await??;
-
- let accept = AcceptFollowCommunity {
- actor: ObjectId::new(community.actor_id()),
- to: ObjectId::new(person.actor_id()),
+impl AcceptFollow {
+ #[tracing::instrument(skip_all)]
+ pub async fn send(follow: Follow, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
+ let user_or_community = follow.object.dereference_local(context).await?;
+ let person = follow.actor.clone().dereference(context).await?;
+ let accept = AcceptFollow {
+ actor: user_or_community.id().into(),
+ to: Some([person.id().into()]),