lemmy/crates/apub/src/activities/following/mod.rs
Louis GERARD 7bc64ab91a
Remove follow community traits (#3737)
* chore(FollowCommunity): remove Perform and Send Activity traits

* chore(FollowCommunity): avoid fetching community and person from db
2023-08-02 11:32:16 +02:00

27 lines
787 B
Rust

use crate::{
objects::{community::ApubCommunity, person::ApubPerson},
protocol::activities::following::{follow::Follow, undo_follow::UndoFollow},
};
use activitypub_federation::config::Data;
use lemmy_api_common::context::LemmyContext;
use lemmy_db_schema::source::{community::Community, person::Person};
use lemmy_utils::error::LemmyError;
pub mod accept;
pub mod follow;
pub mod undo_follow;
pub async fn send_follow_community(
community: Community,
person: Person,
follow: bool,
context: &Data<LemmyContext>,
) -> Result<(), LemmyError> {
let community: ApubCommunity = community.into();
let actor: ApubPerson = person.into();
if follow {
Follow::send(&actor, &community, context).await
} else {
UndoFollow::send(&actor, &community, context).await
}
}