Remove unnecessary InCommunity impls (fixes #5700) (#5715)

This commit is contained in:
Nutomic 2025-05-30 14:33:53 +00:00 committed by GitHub
parent 0de0ca2f07
commit df94566f3c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 10 additions and 55 deletions

View file

@ -95,7 +95,7 @@ impl ActivityHandler for UndoLockPage {
}
async fn verify(&self, context: &Data<Self::DataType>) -> Result<(), Self::Error> {
let community = self.community(context).await?;
let community = self.object.community(context).await?;
verify_visibility(&self.to, &self.cc, &community)?;
verify_person_in_community(&self.actor, &community, context).await?;
check_community_deleted_or_removed(&community)?;

View file

@ -52,7 +52,7 @@ impl ActivityHandler for UndoVote {
}
async fn verify(&self, context: &Data<LemmyContext>) -> LemmyResult<()> {
let community = self.community(context).await?;
let community = self.object.community(context).await?;
verify_person_in_community(&self.actor, &community, context).await?;
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
self.object.verify(context).await?;

View file

@ -80,16 +80,16 @@ impl InCommunity for AnnouncableActivities {
CreateOrUpdateNoteWrapper(a) => a.community(context).await,
CreateOrUpdatePost(a) => a.community(context).await,
Vote(a) => a.community(context).await,
UndoVote(a) => a.community(context).await,
UndoVote(a) => a.object.community(context).await,
Delete(a) => a.community(context).await,
UndoDelete(a) => a.community(context).await,
UndoDelete(a) => a.object.community(context).await,
UpdateCommunity(a) => a.community(context).await,
BlockUser(a) => a.community(context).await,
UndoBlockUser(a) => a.community(context).await,
UndoBlockUser(a) => a.object.community(context).await,
CollectionAdd(a) => a.community(context).await,
CollectionRemove(a) => a.community(context).await,
LockPost(a) => a.community(context).await,
UndoLockPost(a) => a.community(context).await,
UndoLockPost(a) => a.object.community(context).await,
Report(a) => a.community(context).await,
ResolveReport(a) => a.object.community(context).await,
Page(_) => Err(LemmyErrorType::NotFound.into()),

View file

@ -1,16 +1,10 @@
use super::block_user::BlockUser;
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::activity::UndoType,
protocol::helpers::deserialize_one_or_many,
};
use lemmy_api_common::context::LemmyContext;
use lemmy_apub_objects::{
objects::{community::ApubCommunity, person::ApubPerson},
utils::protocol::InCommunity,
};
use lemmy_utils::error::LemmyResult;
use lemmy_apub_objects::objects::person::ApubPerson;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;
@ -33,10 +27,3 @@ pub struct UndoBlockUser {
/// TODO: send a separate Delete activity instead
pub(crate) restore_data: Option<bool>,
}
impl InCommunity for UndoBlockUser {
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
let community = self.object.community(context).await?;
Ok(community)
}
}

View file

@ -59,10 +59,3 @@ impl InCommunity for LockPage {
Ok(community.into())
}
}
impl InCommunity for UndoLockPage {
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
let community = self.object.community(context).await?;
Ok(community)
}
}

View file

@ -1,16 +1,10 @@
use super::delete::Delete;
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::activity::UndoType,
protocol::helpers::deserialize_one_or_many,
};
use lemmy_api_common::context::LemmyContext;
use lemmy_apub_objects::{
objects::{community::ApubCommunity, person::ApubPerson},
utils::protocol::InCommunity,
};
use lemmy_utils::error::LemmyResult;
use lemmy_apub_objects::objects::person::ApubPerson;
use serde::{Deserialize, Serialize};
use serde_with::skip_serializing_none;
use url::Url;
@ -31,10 +25,3 @@ pub struct UndoDelete {
#[serde(skip_serializing_if = "Vec::is_empty")]
pub(crate) cc: Vec<Url>,
}
impl InCommunity for UndoDelete {
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
let community = self.object.community(context).await?;
Ok(community)
}
}

View file

@ -1,11 +1,6 @@
use super::vote::Vote;
use activitypub_federation::{config::Data, fetch::object_id::ObjectId, kinds::activity::UndoType};
use lemmy_api_common::context::LemmyContext;
use lemmy_apub_objects::{
objects::{community::ApubCommunity, person::ApubPerson},
utils::protocol::InCommunity,
};
use lemmy_utils::error::LemmyResult;
use activitypub_federation::{fetch::object_id::ObjectId, kinds::activity::UndoType};
use lemmy_apub_objects::objects::person::ApubPerson;
use serde::{Deserialize, Serialize};
use url::Url;
@ -18,10 +13,3 @@ pub struct UndoVote {
pub(crate) kind: UndoType,
pub(crate) id: Url,
}
impl InCommunity for UndoVote {
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
let community = self.object.community(context).await?;
Ok(community)
}
}