4 verify_person_in_community,
5 voting::{undo_vote_comment, undo_vote_post},
8 objects::{community::ApubCommunity, person::ApubPerson},
10 activities::voting::{undo_vote::UndoVote, vote::Vote},
16 use activitypub_federation::{
17 core::object_id::ObjectId,
19 traits::ActivityHandler,
20 utils::verify_urls_match,
22 use activitystreams_kinds::activity::UndoType;
23 use lemmy_api_common::context::LemmyContext;
24 use lemmy_utils::error::LemmyError;
28 pub(in crate::activities::voting) fn new(
31 community: &ApubCommunity,
32 context: &LemmyContext,
33 ) -> Result<Self, LemmyError> {
35 actor: ObjectId::new(actor.actor_id()),
38 id: generate_activity_id(
40 &context.settings().get_protocol_and_hostname(),
42 audience: Some(ObjectId::new(community.actor_id())),
47 #[async_trait::async_trait(?Send)]
48 impl ActivityHandler for UndoVote {
49 type DataType = LemmyContext;
50 type Error = LemmyError;
52 fn id(&self) -> &Url {
56 fn actor(&self) -> &Url {
60 #[tracing::instrument(skip_all)]
63 context: &Data<LemmyContext>,
64 request_counter: &mut i32,
65 ) -> Result<(), LemmyError> {
66 let community = self.community(context, request_counter).await?;
67 verify_person_in_community(&self.actor, &community, context, request_counter).await?;
68 verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
69 self.object.verify(context, request_counter).await?;
73 #[tracing::instrument(skip_all)]
76 context: &Data<LemmyContext>,
77 request_counter: &mut i32,
78 ) -> Result<(), LemmyError> {
81 .dereference(context, local_instance(context).await, request_counter)
86 .dereference(context, local_instance(context).await, request_counter)
89 PostOrComment::Post(p) => undo_vote_post(actor, &p, context).await,
90 PostOrComment::Comment(c) => undo_vote_comment(actor, &c, context).await,