|
|
|
@ -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())?;
|
|
|
|
|
}
|
|
|
|
|