protocol::verification::verify_urls_match,
traits::{ActivityHandler, Actor},
};
-use lemmy_api_common::{
- community::CommunityResponse,
- context::LemmyContext,
- websocket::UserOperation,
-};
-use lemmy_db_schema::{
- source::{actor_language::CommunityLanguage, community::CommunityFollower},
- traits::Followable,
-};
-use lemmy_db_views::structs::LocalUserView;
-use lemmy_db_views_actor::structs::CommunityView;
+use lemmy_api_common::context::LemmyContext;
+use lemmy_db_schema::{source::community::CommunityFollower, traits::Followable};
use lemmy_utils::error::LemmyError;
use url::Url;
let person = follow.actor.clone().dereference(context).await?;
let accept = AcceptFollow {
actor: user_or_community.id().into(),
+ to: Some([person.id().into()]),
object: follow,
kind: AcceptType::Accept,
id: generate_activity_id(
async fn verify(&self, context: &Data<LemmyContext>) -> Result<(), LemmyError> {
verify_urls_match(self.actor.inner(), self.object.object.inner())?;
self.object.verify(context).await?;
+ if let Some(to) = &self.to {
+ verify_urls_match(to[0].inner(), self.object.actor.inner())?;
+ }
Ok(())
}
// This will throw an error if no follow was requested
let community_id = community.id;
let person_id = person.id;
- CommunityFollower::follow_accepted(context.pool(), community_id, person_id).await?;
-
- // Send the Subscribed message over websocket
- // Re-read the community_view to get the new SubscribedType
- let community_view =
- CommunityView::read(context.pool(), community_id, Some(person_id), None).await?;
-
- // Get the local_user_id
- let local_recipient_id = LocalUserView::read_person(context.pool(), person_id)
- .await?
- .local_user
- .id;
- let discussion_languages = CommunityLanguage::read(context.pool(), community_id).await?;
-
- let response = CommunityResponse {
- community_view,
- discussion_languages,
- };
-
- context
- .chat_server()
- .send_user_room_message(
- &UserOperation::FollowCommunity,
- &response,
- local_recipient_id,
- None,
- )
- .await?;
+ CommunityFollower::follow_accepted(&mut context.pool(), community_id, person_id).await?;
Ok(())
}