2 activities::verify_community_matches,
3 objects::{community::ApubCommunity, person::ApubPerson},
4 protocol::{activities::voting::vote::Vote, InCommunity},
6 use activitypub_federation::{config::Data, fetch::object_id::ObjectId, kinds::activity::UndoType};
7 use lemmy_api_common::context::LemmyContext;
8 use lemmy_utils::error::LemmyError;
9 use serde::{Deserialize, Serialize};
12 #[derive(Clone, Debug, Deserialize, Serialize)]
13 #[serde(rename_all = "camelCase")]
15 pub(crate) actor: ObjectId<ApubPerson>,
16 pub(crate) object: Vote,
17 #[serde(rename = "type")]
18 pub(crate) kind: UndoType,
20 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
23 #[async_trait::async_trait]
24 impl InCommunity for UndoVote {
25 async fn community(&self, context: &Data<LemmyContext>) -> Result<ApubCommunity, LemmyError> {
26 let community = self.object.community(context).await?;
27 if let Some(audience) = &self.audience {
28 verify_community_matches(audience, community.actor_id.clone())?;