From 3fefc89a2e4d9bba6012147f2f8d7a32fc9ef567 Mon Sep 17 00:00:00 2001 From: Felix Ableitner Date: Thu, 2 May 2024 16:28:12 +0200 Subject: [PATCH] cleanup --- crates/apub/src/protocol/objects/page.rs | 13 ++++++------- crates/utils/src/error.rs | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/crates/apub/src/protocol/objects/page.rs b/crates/apub/src/protocol/objects/page.rs index 4141791aa..49faac09a 100644 --- a/crates/apub/src/protocol/objects/page.rs +++ b/crates/apub/src/protocol/objects/page.rs @@ -233,6 +233,10 @@ impl ActivityHandler for Page { #[async_trait::async_trait] impl InCommunity for Page { async fn community(&self, context: &Data) -> LemmyResult { + 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::::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())?; } diff --git a/crates/utils/src/error.rs b/crates/utils/src/error.rs index 6cfd0aaed..00ef82033 100644 --- a/crates/utils/src/error.rs +++ b/crates/utils/src/error.rs @@ -99,8 +99,6 @@ pub enum LemmyErrorType { PersonIsBannedFromSite(String), InvalidVoteValue, PageDoesNotSpecifyCreator, - PageDoesNotSpecifyGroup, - NoCommunityFoundInCc, NoEmailSetup, LocalSiteNotSetup, EmailSmtpServerNeedsAPort,