2 objects::community::ApubCommunity,
3 protocol::activities::following::{follow::Follow, undo_follow::UndoFollow},
6 use activitypub_federation::config::Data;
7 use lemmy_api_common::{
8 community::{CommunityResponse, FollowCommunity},
10 utils::local_user_view_from_jwt,
12 use lemmy_db_schema::{source::community::Community, traits::Crud};
13 use lemmy_utils::error::LemmyError;
19 #[async_trait::async_trait]
20 impl SendActivity for FollowCommunity {
21 type Response = CommunityResponse;
23 async fn send_activity(
25 _response: &Self::Response,
26 context: &Data<LemmyContext>,
27 ) -> Result<(), LemmyError> {
28 let local_user_view = local_user_view_from_jwt(&request.auth, context).await?;
29 let person = local_user_view.person.clone().into();
30 let community: ApubCommunity = Community::read(&mut context.pool(), request.community_id)
35 } else if request.follow {
36 Follow::send(&person, &community, context).await
38 UndoFollow::send(&person, &community, context).await