X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fapub%2Fsrc%2Factivities%2Ffollowing%2Ffollow.rs;h=2f0f5037aed69d6d3abed8572bb0a5afe2b68f1c;hb=e9e76549a88cfbdab36f00d302cceabcaaa24f4c;hp=4e2acd518f530c02f9a5679d101674801b07e9a8;hpb=a25faf3e9743ccf8c24357ec28539230f692b10c;p=lemmy.git diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index 4e2acd51..2f0f5037 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -6,7 +6,7 @@ use crate::{ verify_person_in_community, }, fetcher::user_or_community::UserOrCommunity, - insert_activity, + insert_received_activity, objects::{community::ApubCommunity, person::ApubPerson}, protocol::activities::following::{ accept::AcceptFollow, @@ -24,7 +24,7 @@ use activitypub_federation::{ use lemmy_api_common::{ community::{BlockCommunity, BlockCommunityResponse}, context::LemmyContext, - utils::get_local_user_view_from_jwt, + utils::local_user_view_from_jwt, }; use lemmy_db_schema::{ source::{ @@ -65,7 +65,7 @@ impl Follow { person_id: actor.id, pending: true, }; - CommunityFollower::follow(context.pool(), &community_follower_form) + CommunityFollower::follow(&mut context.pool(), &community_follower_form) .await .ok(); @@ -90,6 +90,7 @@ impl ActivityHandler for Follow { #[tracing::instrument(skip_all)] async fn verify(&self, context: &Data) -> Result<(), LemmyError> { + insert_received_activity(&self.id, context).await?; verify_person(&self.actor, context).await?; let object = self.object.dereference(context).await?; if let UserOrCommunity::Community(c) = object { @@ -103,7 +104,6 @@ impl ActivityHandler for Follow { #[tracing::instrument(skip_all)] async fn receive(self, context: &Data) -> Result<(), LemmyError> { - insert_activity(&self.id, &self, false, true, context).await?; let actor = self.actor.dereference(context).await?; let object = self.object.dereference(context).await?; match object { @@ -113,7 +113,7 @@ impl ActivityHandler for Follow { follower_id: actor.id, pending: false, }; - PersonFollower::follow(context.pool(), &form).await?; + PersonFollower::follow(&mut context.pool(), &form).await?; } UserOrCommunity::Community(c) => { let form = CommunityFollowerForm { @@ -121,7 +121,7 @@ impl ActivityHandler for Follow { person_id: actor.id, pending: false, }; - CommunityFollower::follow(context.pool(), &form).await?; + CommunityFollower::follow(&mut context.pool(), &form).await?; } } @@ -138,9 +138,8 @@ impl SendActivity for BlockCommunity { _response: &Self::Response, context: &Data, ) -> Result<(), LemmyError> { - let local_user_view = - get_local_user_view_from_jwt(&request.auth, context.pool(), context.secret()).await?; - let community = Community::read(context.pool(), request.community_id).await?; + let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; + let community = Community::read(&mut context.pool(), request.community_id).await?; UndoFollow::send(&local_user_view.person.into(), &community.into(), context).await } }