to: Vec<Url>,
object: ObjectId<ApubPerson>,
target: Url,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: AddType,
id: Url,
to: vec![public()],
object: ObjectId::new(added_mod.actor_id()),
target: generate_moderators_url(&community.actor_id)?.into(),
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: AddType::Add,
id: id.clone(),
context: lemmy_context(),
verify_activity(self, &context.settings())?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
- verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
- verify_add_remove_moderator_target(&self.target, &self.cc[0])?;
+ verify_mod_action(&self.actor, &community, context, request_counter).await?;
+ verify_add_remove_moderator_target(&self.target, &community)?;
Ok(())
}
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
pub(in crate::activities::community) object: ObjectId<ApubPerson>,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
target: ObjectId<ApubCommunity>,
#[serde(rename = "type")]
kind: BlockType,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object: ObjectId::new(target.actor_id()),
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
target: ObjectId::new(community.actor_id()),
kind: BlockType::Block,
id: generate_activity_id(
verify_activity(self, &context.settings())?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
- verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
+ verify_mod_action(&self.actor, &community, context, request_counter).await?;
Ok(())
}
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
pub(in crate::activities) object: ObjectId<ApubPerson>,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: RemoveType,
pub(in crate::activities) target: Url,
target: generate_moderators_url(&community.actor_id)?.into(),
id: id.clone(),
context: lemmy_context(),
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: RemoveType::Remove,
unparsed: Default::default(),
};
verify_activity(self, &context.settings())?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
- verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
- verify_add_remove_moderator_target(&self.target, &self.cc[0])?;
+ verify_mod_action(&self.actor, &community, context, request_counter).await?;
+ verify_add_remove_moderator_target(&self.target, &community)?;
Ok(())
}
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
object: BlockUserFromCommunity,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: UndoType,
id: Url,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object: block,
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: UndoType::Undo,
id: id.clone(),
context: lemmy_context(),
verify_activity(self, &context.settings())?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
- verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
+ verify_mod_action(&self.actor, &community, context, request_counter).await?;
self.object.verify(context, request_counter).await?;
Ok(())
}
to: Vec<Url>,
// TODO: would be nice to use a separate struct here, which only contains the fields updated here
object: Group,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: UpdateType,
id: Url,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object: community.to_apub(context).await?,
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: UpdateType::Update,
id: id.clone(),
context: lemmy_context(),
verify_activity(self, &context.settings())?;
let community = self.get_community(context, request_counter).await?;
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
- verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
+ verify_mod_action(&self.actor, &community, context, request_counter).await?;
Ok(())
}
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
pub(in crate::activities::deletion) object: Url,
- pub(in crate::activities::deletion) cc: [ObjectId<ApubCommunity>; 1],
+ pub(in crate::activities::deletion) cc: Vec<Url>,
#[serde(rename = "type")]
kind: DeleteType,
/// If summary is present, this is a mod action (Remove in Lemmy terms). Otherwise, its a user
) -> Result<(), LemmyError> {
verify_is_public(&self.to)?;
verify_activity(self, &context.settings())?;
+ let community = self.get_community(context, request_counter).await?;
verify_delete_activity(
&self.object,
self,
- &self.cc[0],
+ &community,
self.summary.is_some(),
context,
request_counter,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object: object_id,
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: DeleteType::Delete,
summary,
id: generate_activity_id(
pub(in crate::activities) async fn verify_delete_activity(
object: &Url,
activity: &dyn ActivityFields,
- community_id: &ObjectId<ApubCommunity>,
+ community: &ApubCommunity,
is_mod_action: bool,
context: &LemmyContext,
request_counter: &mut i32,
let object = DeletableObjects::read_from_db(object, context).await?;
let actor = ObjectId::new(activity.actor().clone());
match object {
- DeletableObjects::Community(c) => {
- if c.local {
+ DeletableObjects::Community(community) => {
+ if community.local {
// can only do this check for local community, in remote case it would try to fetch the
// deleted community (which fails)
- verify_person_in_community(&actor, &c, context, request_counter).await?;
+ verify_person_in_community(&actor, &community, context, request_counter).await?;
}
// community deletion is always a mod (or admin) action
- verify_mod_action(
- &actor,
- &ObjectId::new(c.actor_id()),
- context,
- request_counter,
- )
- .await?;
+ verify_mod_action(&actor, &community, context, request_counter).await?;
}
DeletableObjects::Post(p) => {
verify_delete_activity_post_or_comment(
activity,
&p.ap_id.clone().into(),
- community_id,
+ community,
is_mod_action,
context,
request_counter,
verify_delete_activity_post_or_comment(
activity,
&c.ap_id.clone().into(),
- community_id,
+ community,
is_mod_action,
context,
request_counter,
async fn verify_delete_activity_post_or_comment(
activity: &dyn ActivityFields,
object_id: &Url,
- community_id: &ObjectId<ApubCommunity>,
+ community: &ApubCommunity,
is_mod_action: bool,
context: &LemmyContext,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
let actor = ObjectId::new(activity.actor().clone());
- let community = community_id.dereference(context, request_counter).await?;
- verify_person_in_community(&actor, &community, context, request_counter).await?;
+ verify_person_in_community(&actor, community, context, request_counter).await?;
if is_mod_action {
- verify_mod_action(&actor, community_id, context, request_counter).await?;
+ verify_mod_action(&actor, community, context, request_counter).await?;
} else {
// domain of post ap_id and post.creator ap_id are identical, so we just check the former
verify_domains_match(activity.actor(), object_id)?;
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
object: Delete,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: UndoType,
id: Url,
verify_is_public(&self.to)?;
verify_activity(self, &context.settings())?;
self.object.verify(context, request_counter).await?;
+ let community = self.get_community(context, request_counter).await?;
verify_delete_activity(
&self.object.object,
self,
- &self.cc[0],
+ &community,
self.object.summary.is_some(),
context,
request_counter,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object,
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: UndoType::Undo,
id: id.clone(),
context: lemmy_context(),
/// is not federated, we cant verify their actions remotely.
pub(crate) async fn verify_mod_action(
actor_id: &ObjectId<ApubPerson>,
- community_id: &ObjectId<ApubCommunity>,
+ community: &ApubCommunity,
context: &LemmyContext,
request_counter: &mut i32,
) -> Result<(), LemmyError> {
- let community = community_id.dereference_local(context).await?;
-
if community.local {
let actor = actor_id.dereference(context, request_counter).await?;
/// /c/community/moderators. Any different values are unsupported.
fn verify_add_remove_moderator_target(
target: &Url,
- community: &ObjectId<ApubCommunity>,
+ community: &ApubCommunity,
) -> Result<(), LemmyError> {
- if target != &generate_moderators_url(&community.clone().into())?.into_inner() {
+ if target != &generate_moderators_url(&community.actor_id)?.into_inner() {
return Err(anyhow!("Unkown target url").into());
}
Ok(())
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
object: Page,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: CreateOrUpdateType,
id: Url,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object: post.to_apub(context).await?,
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind,
id: id.clone(),
context: lemmy_context(),
CreateOrUpdateType::Update => {
let is_mod_action = self.object.is_mod_action(context).await?;
if is_mod_action {
- verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
+ verify_mod_action(&self.actor, &community, context, request_counter).await?;
} else {
verify_domains_match(self.actor.inner(), self.object.id_unchecked())?;
verify_urls_match(self.actor(), self.object.attributed_to.inner())?;
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
object: Vote,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
kind: UndoType,
id: Url,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object,
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: UndoType::Undo,
id: id.clone(),
context: lemmy_context(),
actor: ObjectId<ApubPerson>,
to: Vec<Url>,
pub(in crate::activities::voting) object: ObjectId<PostOrComment>,
- cc: [ObjectId<ApubCommunity>; 1],
+ cc: Vec<Url>,
#[serde(rename = "type")]
pub(in crate::activities::voting) kind: VoteType,
id: Url,
actor: ObjectId::new(actor.actor_id()),
to: vec![public()],
object: ObjectId::new(object.ap_id()),
- cc: [ObjectId::new(community.actor_id())],
+ cc: vec![community.actor_id()],
kind: kind.clone(),
id: generate_activity_id(kind, &context.settings().get_protocol_and_hostname())?,
context: lemmy_context(),