This commit is contained in:
Felix Ableitner 2024-05-02 16:28:12 +02:00
parent 3bc61dd40d
commit 3fefc89a2e
2 changed files with 6 additions and 9 deletions

View file

@ -233,6 +233,10 @@ impl ActivityHandler for Page {
#[async_trait::async_trait]
impl InCommunity for Page {
async fn community(&self, context: &Data<LemmyContext>) -> LemmyResult<ApubCommunity> {
if let Some(audience) = &self.audience {
return audience.dereference(context).await;
}
let community = match &self.attributed_to {
AttributedTo::Lemmy(_) => {
let mut iter = self.to.iter().merge(self.cc.iter());
@ -243,11 +247,7 @@ impl InCommunity for Page {
break c;
}
} else {
let audience = self
.audience
.clone()
.ok_or(LemmyErrorType::NoCommunityFoundInCc)?;
break audience.dereference(context).await?;
Err(LemmyErrorType::CouldntFindCommunity)?;
}
}
}
@ -255,13 +255,12 @@ impl InCommunity for Page {
p.iter()
.find(|a| a.kind == PersonOrGroupType::Group)
.map(|a| ObjectId::<ApubCommunity>::from(a.id.clone().into_inner()))
.ok_or(LemmyErrorType::PageDoesNotSpecifyGroup)?
.ok_or(LemmyErrorType::CouldntFindCommunity)?
.dereference(context)
.await?
}
};
// TODO: doesnt make sense to do this here as were checking audience against itself
if let Some(audience) = &self.audience {
verify_community_matches(audience, community.actor_id.clone())?;
}

View file

@ -99,8 +99,6 @@ pub enum LemmyErrorType {
PersonIsBannedFromSite(String),
InvalidVoteValue,
PageDoesNotSpecifyCreator,
PageDoesNotSpecifyGroup,
NoCommunityFoundInCc,
NoEmailSetup,
LocalSiteNotSetup,
EmailSmtpServerNeedsAPort,