2 activities::verify_community_matches,
4 objects::{community::ApubCommunity, person::ApubPerson},
5 protocol::{activities::voting::vote::Vote, InCommunity},
7 use activitypub_federation::core::object_id::ObjectId;
8 use activitystreams_kinds::activity::UndoType;
9 use lemmy_utils::error::LemmyError;
10 use lemmy_websocket::LemmyContext;
11 use serde::{Deserialize, Serialize};
14 #[derive(Clone, Debug, Deserialize, Serialize)]
15 #[serde(rename_all = "camelCase")]
17 pub(crate) actor: ObjectId<ApubPerson>,
18 pub(crate) object: Vote,
19 #[serde(rename = "type")]
20 pub(crate) kind: UndoType,
22 pub(crate) audience: Option<ObjectId<ApubCommunity>>,
25 #[async_trait::async_trait(?Send)]
26 impl InCommunity for UndoVote {
29 context: &LemmyContext,
30 request_counter: &mut i32,
31 ) -> Result<ApubCommunity, LemmyError> {
32 let local_instance = local_instance(context).await;
33 let object_community = self.object.community(context, request_counter).await?;
34 if let Some(audience) = &self.audience {
35 let audience = audience
36 .dereference(context, local_instance, request_counter)
38 verify_community_matches(&audience, object_community.id)?;