For verify_is_public() we also need to check cc field
This commit is contained in:
parent
a5a674a270
commit
888e683856
17 changed files with 22 additions and 16 deletions
|
@ -75,7 +75,7 @@ impl ActivityHandler for CreateOrUpdateComment {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
let post = self.object.get_parents(context, request_counter).await?.0;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ impl ActivityHandler for AddMod {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -59,7 +59,7 @@ impl ActivityHandler for AnnounceActivity {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
self.object.verify(context, request_counter).await?;
|
||||
Ok(())
|
||||
|
|
|
@ -75,7 +75,7 @@ impl ActivityHandler for BlockUserFromCommunity {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -63,7 +63,7 @@ impl ActivityHandler for RemoveMod {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -65,7 +65,7 @@ impl ActivityHandler for UndoBlockUserFromCommunity {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -58,7 +58,7 @@ impl ActivityHandler for UpdateCommunity {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -50,7 +50,7 @@ impl ActivityHandler for Delete {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_delete_activity(
|
||||
|
|
|
@ -35,7 +35,7 @@ impl ActivityHandler for UndoDelete {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
self.object.verify(context, request_counter).await?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
|
|
|
@ -116,8 +116,8 @@ fn verify_add_remove_moderator_target(
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn verify_is_public(to: &[Url]) -> Result<(), LemmyError> {
|
||||
if !to.contains(&public()) {
|
||||
pub(crate) fn verify_is_public(to: &[Url], cc: &[Url]) -> Result<(), LemmyError> {
|
||||
if !to.contains(&public()) && !cc.contains(&public()) {
|
||||
return Err(anyhow!("Object is not public").into());
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -74,7 +74,7 @@ impl ActivityHandler for CreateOrUpdatePost {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -68,7 +68,7 @@ impl ActivityHandler for UndoVote {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -74,7 +74,7 @@ impl ActivityHandler for Vote {
|
|||
context: &Data<LemmyContext>,
|
||||
request_counter: &mut i32,
|
||||
) -> Result<(), LemmyError> {
|
||||
verify_is_public(&self.to)?;
|
||||
verify_is_public(&self.to, &self.cc)?;
|
||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||
let community = self.get_community(context, request_counter).await?;
|
||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||
|
|
|
@ -107,6 +107,7 @@ impl ApubObject for ApubComment {
|
|||
id: ObjectId::new(self.ap_id.clone()),
|
||||
attributed_to: ObjectId::new(creator.actor_id),
|
||||
to: vec![public()],
|
||||
cc: vec![],
|
||||
content: markdown_to_html(&self.content),
|
||||
media_type: Some(MediaTypeHtml::Html),
|
||||
source: SourceCompat::Lemmy(Source {
|
||||
|
@ -137,7 +138,7 @@ impl ApubObject for ApubComment {
|
|||
) -> Result<(), LemmyError> {
|
||||
verify_domains_match(note.id.inner(), expected_domain)?;
|
||||
verify_domains_match(note.attributed_to.inner(), note.id.inner())?;
|
||||
verify_is_public(¬e.to)?;
|
||||
verify_is_public(¬e.to, ¬e.cc)?;
|
||||
let (post, _) = note.get_parents(context, request_counter).await?;
|
||||
let community_id = post.community_id;
|
||||
let community = blocking(context.pool(), move |conn| {
|
||||
|
|
|
@ -110,6 +110,7 @@ impl ApubObject for ApubPost {
|
|||
id: ObjectId::new(self.ap_id.clone()),
|
||||
attributed_to: ObjectId::new(creator.actor_id),
|
||||
to: vec![community.actor_id.into(), public()],
|
||||
cc: vec![],
|
||||
name: self.name.clone(),
|
||||
content: self.body.as_ref().map(|b| markdown_to_html(b)),
|
||||
media_type: Some(MediaTypeHtml::Html),
|
||||
|
@ -150,7 +151,7 @@ impl ApubObject for ApubPost {
|
|||
verify_person_in_community(&page.attributed_to, &community, context, request_counter).await?;
|
||||
check_slurs(&page.name, &context.settings().slur_regex())?;
|
||||
verify_domains_match(page.attributed_to.inner(), page.id.inner())?;
|
||||
verify_is_public(&page.to.clone())?;
|
||||
verify_is_public(&page.to, &page.cc)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ pub struct Note {
|
|||
pub(crate) id: ObjectId<ApubComment>,
|
||||
pub(crate) attributed_to: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
#[serde(default)]
|
||||
pub(crate) cc: Vec<Url>,
|
||||
pub(crate) content: String,
|
||||
pub(crate) media_type: Option<MediaTypeHtml>,
|
||||
pub(crate) source: SourceCompat,
|
||||
|
|
|
@ -20,6 +20,8 @@ pub struct Page {
|
|||
pub(crate) id: ObjectId<ApubPost>,
|
||||
pub(crate) attributed_to: ObjectId<ApubPerson>,
|
||||
pub(crate) to: Vec<Url>,
|
||||
#[serde(default)]
|
||||
pub(crate) cc: Vec<Url>,
|
||||
pub(crate) name: String,
|
||||
pub(crate) content: Option<String>,
|
||||
pub(crate) media_type: Option<MediaTypeHtml>,
|
||||
|
|
Loading…
Reference in a new issue