]> Untitled Git - lemmy.git/commitdiff
Activity.to should always be a vec (and unspecified size for public activities)
authorFelix Ableitner <me@nutomic.com>
Mon, 25 Oct 2021 17:22:34 +0000 (19:22 +0200)
committerFelix Ableitner <me@nutomic.com>
Fri, 29 Oct 2021 10:45:54 +0000 (12:45 +0200)
22 files changed:
crates/apub/src/activities/comment/create_or_update.rs
crates/apub/src/activities/community/add_mod.rs
crates/apub/src/activities/community/announce.rs
crates/apub/src/activities/community/block_user.rs
crates/apub/src/activities/community/remove_mod.rs
crates/apub/src/activities/community/undo_block_user.rs
crates/apub/src/activities/community/update.rs
crates/apub/src/activities/deletion/delete.rs
crates/apub/src/activities/deletion/undo_delete.rs
crates/apub/src/activities/following/accept.rs
crates/apub/src/activities/following/follow.rs
crates/apub/src/activities/following/undo.rs
crates/apub/src/activities/post/create_or_update.rs
crates/apub/src/activities/private_message/create_or_update.rs
crates/apub/src/activities/private_message/delete.rs
crates/apub/src/activities/private_message/undo_delete.rs
crates/apub/src/activities/voting/undo_vote.rs
crates/apub/src/activities/voting/vote.rs
crates/apub/src/http/community.rs
crates/apub/src/http/mod.rs
crates/apub/src/http/person.rs
crates/apub_lib/src/values.rs

index 0dcf3f7d85ddd10e684751dd238d24bd2fb64b58..9ccf49f05fc2168a989644b6454c619dd4444fb5 100644 (file)
@@ -6,6 +6,7 @@ use crate::{
     extract_community,
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_person_in_community,
     CreateOrUpdateType,
   },
@@ -17,12 +18,17 @@ use crate::{
     person::ApubPerson,
   },
 };
-use activitystreams::{base::AnyBase, link::Mention, primitives::OneOrMany, unparsed::Unparsed};
+use activitystreams::{
+  base::AnyBase,
+  link::Mention,
+  primitives::OneOrMany,
+  public,
+  unparsed::Unparsed,
+};
 use lemmy_api_common::{blocking, check_post_deleted_or_removed};
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
-  values::PublicUrl,
   verify::verify_domains_match,
 };
 use lemmy_db_schema::{
@@ -38,7 +44,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct CreateOrUpdateComment {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: Note,
   cc: Vec<Url>,
   tag: Vec<Mention>,
@@ -76,7 +82,7 @@ impl CreateOrUpdateComment {
 
     let create_or_update = CreateOrUpdateComment {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: comment.to_apub(context).await?,
       cc: maa.ccs,
       tag: maa.tags,
@@ -100,6 +106,7 @@ impl ActivityHandler for CreateOrUpdateComment {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     let community = extract_community(&self.cc, context, request_counter).await?;
     let community_id = ObjectId::new(community.actor_id());
     let post = self.object.get_parents(context, request_counter).await?.0;
index e1cf03e0d0238be91c6fdc0c1d5f9bf1594db9da..6df6f8127b9b71024d79e89b944ee3f2238e169d 100644 (file)
@@ -4,6 +4,7 @@ use crate::{
     generate_activity_id,
     verify_activity,
     verify_add_remove_moderator_target,
+    verify_is_public,
     verify_mod_action,
     verify_person_in_community,
   },
@@ -16,13 +17,13 @@ use activitystreams::{
   activity::kind::AddType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{
   source::community::{CommunityModerator, CommunityModeratorForm},
@@ -37,7 +38,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct AddMod {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: ObjectId<ApubPerson>,
   target: Url,
   cc: [ObjectId<ApubCommunity>; 1],
@@ -63,7 +64,7 @@ impl AddMod {
     )?;
     let add = AddMod {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: ObjectId::new(added_mod.actor_id()),
       target: generate_moderators_url(&community.actor_id)?.into(),
       cc: [ObjectId::new(community.actor_id())],
@@ -88,6 +89,7 @@ impl ActivityHandler for AddMod {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
index f3dc72c561d6ccd96d22ede6338182cef330baf6..deca2b73ae617f4722d2cfadffcecac905faaeb7 100644 (file)
@@ -14,6 +14,7 @@ use crate::{
     post::create_or_update::CreateOrUpdatePost,
     verify_activity,
     verify_community,
+    verify_is_public,
     voting::{undo_vote::UndoVote, vote::Vote},
   },
   context::lemmy_context,
@@ -28,12 +29,12 @@ use activitystreams::{
   activity::kind::AnnounceType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
@@ -61,7 +62,7 @@ pub enum AnnouncableActivities {
 #[serde(rename_all = "camelCase")]
 pub struct AnnounceActivity {
   actor: ObjectId<ApubCommunity>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: AnnouncableActivities,
   cc: Vec<Url>,
   #[serde(rename = "type")]
@@ -82,7 +83,7 @@ impl AnnounceActivity {
   ) -> Result<(), LemmyError> {
     let announce = AnnounceActivity {
       actor: ObjectId::new(community.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object,
       cc: vec![community.followers_url()],
       kind: AnnounceType::Announce,
@@ -106,6 +107,7 @@ impl ActivityHandler for AnnounceActivity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_community(&self.actor, context, request_counter).await?;
     self.object.verify(context, request_counter).await?;
index a1c76c23b88d47d4c21116dd8b8868447ce3a60f..64a030c8bc7c0c103e4e16e121a5539b1b4a5364 100644 (file)
@@ -3,6 +3,7 @@ use crate::{
     community::{announce::AnnouncableActivities, send_to_community},
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_mod_action,
     verify_person_in_community,
   },
@@ -14,13 +15,13 @@ use activitystreams::{
   activity::kind::BlockType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{
   source::community::{
@@ -40,7 +41,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct BlockUserFromCommunity {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   pub(in crate::activities::community) object: ObjectId<ApubPerson>,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -61,7 +62,7 @@ impl BlockUserFromCommunity {
   ) -> Result<BlockUserFromCommunity, LemmyError> {
     Ok(BlockUserFromCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: ObjectId::new(target.actor_id()),
       cc: [ObjectId::new(community.actor_id())],
       kind: BlockType::Block,
@@ -97,6 +98,7 @@ impl ActivityHandler for BlockUserFromCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
index 9f4c9ae627c2638a0cbc89bfcfa4f1e13a757f40..d1a5675a51563a18afd6fad572c543d6f5614d68 100644 (file)
@@ -4,6 +4,7 @@ use crate::{
     generate_activity_id,
     verify_activity,
     verify_add_remove_moderator_target,
+    verify_is_public,
     verify_mod_action,
     verify_person_in_community,
   },
@@ -16,13 +17,13 @@ use activitystreams::{
   activity::kind::RemoveType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{
   source::community::{CommunityModerator, CommunityModeratorForm},
@@ -37,7 +38,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct RemoveMod {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   pub(in crate::activities) object: ObjectId<ApubPerson>,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -64,7 +65,7 @@ impl RemoveMod {
     )?;
     let remove = RemoveMod {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: ObjectId::new(removed_mod.actor_id()),
       target: generate_moderators_url(&community.actor_id)?.into(),
       id: id.clone(),
@@ -88,6 +89,7 @@ impl ActivityHandler for RemoveMod {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
index 1614de672d9b131439ddbf425326fca5950c50f0..ee36d1ae3994054daab45e8380330d861bda95a5 100644 (file)
@@ -7,6 +7,7 @@ use crate::{
     },
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_mod_action,
     verify_person_in_community,
   },
@@ -18,13 +19,13 @@ use activitystreams::{
   activity::kind::UndoType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{
   source::community::{CommunityPersonBan, CommunityPersonBanForm},
@@ -39,7 +40,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UndoBlockUserFromCommunity {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: BlockUserFromCommunity,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -66,7 +67,7 @@ impl UndoBlockUserFromCommunity {
     )?;
     let undo = UndoBlockUserFromCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: block,
       cc: [ObjectId::new(community.actor_id())],
       kind: UndoType::Undo,
@@ -89,6 +90,7 @@ impl ActivityHandler for UndoBlockUserFromCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
index f6d693dd6b073f78e126b74799ca3ef464c576f5..6c78dbfb9b724e0d389f0e539f69820bbc7ee0e7 100644 (file)
@@ -3,6 +3,7 @@ use crate::{
     community::{announce::AnnouncableActivities, send_to_community},
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_mod_action,
     verify_person_in_community,
   },
@@ -17,13 +18,13 @@ use activitystreams::{
   activity::kind::UpdateType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{
   source::community::{Community, CommunityForm},
@@ -40,7 +41,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UpdateCommunity {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  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],
@@ -65,7 +66,7 @@ impl UpdateCommunity {
     )?;
     let update = UpdateCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: community.to_apub(context).await?,
       cc: [ObjectId::new(community.actor_id())],
       kind: UpdateType::Update,
@@ -87,6 +88,7 @@ impl ActivityHandler for UpdateCommunity {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     verify_mod_action(&self.actor, &self.cc[0], context, request_counter).await?;
index 02df7dc38a2d87de5f133179fa09689e55060e3a..7593c5bf48ac53b61a9e0154c58b903256383767 100644 (file)
@@ -9,6 +9,7 @@ use crate::{
     },
     generate_activity_id,
     verify_activity,
+    verify_is_public,
   },
   context::lemmy_context,
   fetcher::object_id::ObjectId,
@@ -18,6 +19,7 @@ use activitystreams::{
   activity::kind::DeleteType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use anyhow::anyhow;
@@ -25,7 +27,6 @@ use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{
   source::{
@@ -66,7 +67,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct Delete {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   pub(in crate::activities::deletion) object: Url,
   pub(in crate::activities::deletion) cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -89,6 +90,7 @@ impl ActivityHandler for Delete {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_delete_activity(
       &self.object,
@@ -144,7 +146,7 @@ impl Delete {
   ) -> Result<Delete, LemmyError> {
     Ok(Delete {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: object_id,
       cc: [ObjectId::new(community.actor_id())],
       kind: DeleteType::Delete,
index 327bf86c03a6ac28888d733b62f149f36c4fc6da..87c8eae7f00203fe34abcde699c352bb0b427738 100644 (file)
@@ -10,6 +10,7 @@ use crate::{
     },
     generate_activity_id,
     verify_activity,
+    verify_is_public,
   },
   context::lemmy_context,
   fetcher::object_id::ObjectId,
@@ -19,6 +20,7 @@ use activitystreams::{
   activity::kind::UndoType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use anyhow::anyhow;
@@ -26,7 +28,6 @@ use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::source::{comment::Comment, community::Community, post::Post};
 use lemmy_utils::LemmyError;
@@ -42,7 +43,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UndoDelete {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: Delete,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -62,6 +63,7 @@ impl ActivityHandler for UndoDelete {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     self.object.verify(context, request_counter).await?;
     verify_delete_activity(
@@ -117,7 +119,7 @@ impl UndoDelete {
     )?;
     let undo = UndoDelete {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object,
       cc: [ObjectId::new(community.actor_id())],
       kind: UndoType::Undo,
index 6fa65e7b1080d85749940f2afe34706d11a95c00..78d12b52361dc1066adc55b9eae2904e62ec21f9 100644 (file)
@@ -32,7 +32,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct AcceptFollowCommunity {
   actor: ObjectId<ApubCommunity>,
-  to: ObjectId<ApubPerson>,
+  to: [ObjectId<ApubPerson>; 1],
   object: FollowCommunity,
   #[serde(rename = "type")]
   kind: AcceptType,
@@ -57,7 +57,7 @@ impl AcceptFollowCommunity {
       .await?;
     let accept = AcceptFollowCommunity {
       actor: ObjectId::new(community.actor_id()),
-      to: ObjectId::new(person.actor_id()),
+      to: [ObjectId::new(person.actor_id())],
       object: follow,
       kind: AcceptType::Accept,
       id: generate_activity_id(
@@ -82,8 +82,8 @@ impl ActivityHandler for AcceptFollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(self, &context.settings())?;
-    verify_urls_match(self.to.inner(), self.object.actor())?;
-    verify_urls_match(self.actor(), self.object.to.inner())?;
+    verify_urls_match(self.to[0].inner(), self.object.actor())?;
+    verify_urls_match(self.actor(), self.object.to[0].inner())?;
     verify_community(&self.actor, context, request_counter).await?;
     self.object.verify(context, request_counter).await?;
     Ok(())
@@ -95,7 +95,7 @@ impl ActivityHandler for AcceptFollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let actor = self.actor.dereference(context, request_counter).await?;
-    let to = self.to.dereference(context, request_counter).await?;
+    let to = self.to[0].dereference(context, request_counter).await?;
     // This will throw an error if no follow was requested
     blocking(context.pool(), move |conn| {
       CommunityFollower::follow_accepted(conn, actor.id, to.id)
index 144243812a5bc8bea07627384e656ff3aa82acd4..82d2d5408db8ca21af6b239b4e833b51394cf301 100644 (file)
@@ -35,8 +35,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct FollowCommunity {
   pub(in crate::activities::following) actor: ObjectId<ApubPerson>,
-  // TODO: is there any reason to put the same community id twice, in to and object?
-  pub(in crate::activities::following) to: ObjectId<ApubCommunity>,
+  pub(in crate::activities::following) to: [ObjectId<ApubCommunity>; 1],
   pub(in crate::activities::following) object: ObjectId<ApubCommunity>,
   #[serde(rename = "type")]
   kind: FollowType,
@@ -55,7 +54,7 @@ impl FollowCommunity {
   ) -> Result<FollowCommunity, LemmyError> {
     Ok(FollowCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: ObjectId::new(community.actor_id()),
+      to: [ObjectId::new(community.actor_id())],
       object: ObjectId::new(community.actor_id()),
       kind: FollowType::Follow,
       id: generate_activity_id(
@@ -96,7 +95,7 @@ impl ActivityHandler for FollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(self, &context.settings())?;
-    verify_urls_match(self.to.inner(), self.object.inner())?;
+    verify_urls_match(self.to[0].inner(), self.object.inner())?;
     verify_person(&self.actor, context, request_counter).await?;
     Ok(())
   }
@@ -107,7 +106,7 @@ impl ActivityHandler for FollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let actor = self.actor.dereference(context, request_counter).await?;
-    let community = self.object.dereference(context, request_counter).await?;
+    let community = self.to[0].dereference(context, request_counter).await?;
     let community_follower_form = CommunityFollowerForm {
       community_id: community.id,
       person_id: actor.id,
index 5c548ae4835861791a7974585b057067fa1aaa83..7abb611780d1d5431521f8de6e3aacb26c34cf42 100644 (file)
@@ -35,7 +35,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UndoFollowCommunity {
   actor: ObjectId<ApubPerson>,
-  to: ObjectId<ApubCommunity>,
+  to: [ObjectId<ApubCommunity>; 1],
   object: FollowCommunity,
   #[serde(rename = "type")]
   kind: UndoType,
@@ -55,7 +55,7 @@ impl UndoFollowCommunity {
     let object = FollowCommunity::new(actor, community, context)?;
     let undo = UndoFollowCommunity {
       actor: ObjectId::new(actor.actor_id()),
-      to: ObjectId::new(community.actor_id()),
+      to: [ObjectId::new(community.actor_id())],
       object,
       kind: UndoType::Undo,
       id: generate_activity_id(
@@ -79,7 +79,7 @@ impl ActivityHandler for UndoFollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     verify_activity(self, &context.settings())?;
-    verify_urls_match(self.to.inner(), self.object.object.inner())?;
+    verify_urls_match(self.to[0].inner(), self.object.object.inner())?;
     verify_urls_match(self.actor(), self.object.actor())?;
     verify_person(&self.actor, context, request_counter).await?;
     self.object.verify(context, request_counter).await?;
@@ -92,7 +92,7 @@ impl ActivityHandler for UndoFollowCommunity {
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
     let actor = self.actor.dereference(context, request_counter).await?;
-    let community = self.to.dereference(context, request_counter).await?;
+    let community = self.to[0].dereference(context, request_counter).await?;
 
     let community_follower_form = CommunityFollowerForm {
       community_id: community.id,
index 4a048a965bda4deddf34cec092de567d0e097afc..b3c0b6942462006d54f2612223b1812a41bf7a98 100644 (file)
@@ -4,6 +4,7 @@ use crate::{
     community::{announce::AnnouncableActivities, send_to_community},
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_mod_action,
     verify_person_in_community,
     CreateOrUpdateType,
@@ -16,13 +17,12 @@ use crate::{
     post::{ApubPost, Page},
   },
 };
-use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed};
+use activitystreams::{base::AnyBase, primitives::OneOrMany, public, unparsed::Unparsed};
 use anyhow::anyhow;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType, ApubObject},
-  values::PublicUrl,
   verify::{verify_domains_match, verify_urls_match},
 };
 use lemmy_db_schema::{source::community::Community, traits::Crud};
@@ -35,7 +35,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct CreateOrUpdatePost {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: Page,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -61,7 +61,7 @@ impl CreateOrUpdatePost {
     )?;
     Ok(CreateOrUpdatePost {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: post.to_apub(context).await?,
       cc: [ObjectId::new(community.actor_id())],
       kind,
@@ -97,6 +97,7 @@ impl ActivityHandler for CreateOrUpdatePost {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     let community = self.cc[0].dereference(context, request_counter).await?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
index 9ef22f0e459a3b8b58d9c50a159f8039a6b2e0a8..d6552b37a5e16c3949574665d8b3e467fdae625e 100644 (file)
@@ -28,7 +28,7 @@ pub struct CreateOrUpdatePrivateMessage {
   pub context: OneOrMany<AnyBase>,
   id: Url,
   actor: ObjectId<ApubPerson>,
-  to: ObjectId<ApubPerson>,
+  to: [ObjectId<ApubPerson>; 1],
   object: Note,
   #[serde(rename = "type")]
   kind: CreateOrUpdateType,
@@ -57,7 +57,7 @@ impl CreateOrUpdatePrivateMessage {
       context: lemmy_context(),
       id: id.clone(),
       actor: ObjectId::new(actor.actor_id()),
-      to: ObjectId::new(recipient.actor_id()),
+      to: [ObjectId::new(recipient.actor_id())],
       object: private_message.to_apub(context).await?,
       kind,
       unparsed: Default::default(),
index bb374eb47a0582023fbe6956108f9f71d1e651cf..bcd9542c9c207cee54f829c08b3defb228162581 100644 (file)
@@ -30,7 +30,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct DeletePrivateMessage {
   actor: ObjectId<ApubPerson>,
-  to: ObjectId<ApubPerson>,
+  to: [ObjectId<ApubPerson>; 1],
   pub(in crate::activities::private_message) object: ObjectId<ApubPrivateMessage>,
   #[serde(rename = "type")]
   kind: DeleteType,
@@ -49,7 +49,7 @@ impl DeletePrivateMessage {
   ) -> Result<DeletePrivateMessage, LemmyError> {
     Ok(DeletePrivateMessage {
       actor: ObjectId::new(actor.actor_id()),
-      to: ObjectId::new(actor.actor_id()),
+      to: [ObjectId::new(actor.actor_id())],
       object: ObjectId::new(pm.ap_id.clone()),
       kind: DeleteType::Delete,
       id: generate_activity_id(
index 0263b81156a40112cca31db5966cd9d099e6a14e..cdabaa9aa6766b8170107936f0ef3f316b796357 100644 (file)
@@ -35,7 +35,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UndoDeletePrivateMessage {
   actor: ObjectId<ApubPerson>,
-  to: ObjectId<ApubPerson>,
+  to: [ObjectId<ApubPerson>; 1],
   object: DeletePrivateMessage,
   #[serde(rename = "type")]
   kind: UndoType,
@@ -65,7 +65,7 @@ impl UndoDeletePrivateMessage {
     )?;
     let undo = UndoDeletePrivateMessage {
       actor: ObjectId::new(actor.actor_id()),
-      to: ObjectId::new(recipient.actor_id()),
+      to: [ObjectId::new(recipient.actor_id())],
       object,
       kind: UndoType::Undo,
       id: id.clone(),
index d72b5245dce641f5bae0a0e472b108c371d4efe6..1ac1d4d8d3f95cb835026cf88f06497aabbd6322 100644 (file)
@@ -3,6 +3,7 @@ use crate::{
     community::{announce::AnnouncableActivities, send_to_community},
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_person_in_community,
     voting::{
       undo_vote_comment,
@@ -19,13 +20,13 @@ use activitystreams::{
   activity::kind::UndoType,
   base::AnyBase,
   primitives::OneOrMany,
+  public,
   unparsed::Unparsed,
 };
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
   verify::verify_urls_match,
 };
 use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
@@ -39,7 +40,7 @@ use url::Url;
 #[serde(rename_all = "camelCase")]
 pub struct UndoVote {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   object: Vote,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -72,7 +73,7 @@ impl UndoVote {
     )?;
     let undo_vote = UndoVote {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object,
       cc: [ObjectId::new(community.actor_id())],
       kind: UndoType::Undo,
@@ -93,6 +94,7 @@ impl ActivityHandler for UndoVote {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     verify_urls_match(self.actor(), self.object.actor())?;
index 5d4c9066e51f63bee436928f9964b8399e458b1d..166ce73310e882716457354506b39bd847aad6b8 100644 (file)
@@ -3,6 +3,7 @@ use crate::{
     community::{announce::AnnouncableActivities, send_to_community},
     generate_activity_id,
     verify_activity,
+    verify_is_public,
     verify_person_in_community,
     voting::{vote_comment, vote_post},
   },
@@ -11,13 +12,12 @@ use crate::{
   objects::{community::ApubCommunity, person::ApubPerson},
   PostOrComment,
 };
-use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed};
+use activitystreams::{base::AnyBase, primitives::OneOrMany, public, unparsed::Unparsed};
 use anyhow::anyhow;
 use lemmy_api_common::blocking;
 use lemmy_apub_lib::{
   data::Data,
   traits::{ActivityFields, ActivityHandler, ActorType},
-  values::PublicUrl,
 };
 use lemmy_db_schema::{newtypes::CommunityId, source::community::Community, traits::Crud};
 use lemmy_utils::LemmyError;
@@ -58,7 +58,7 @@ impl From<&VoteType> for i16 {
 #[serde(rename_all = "camelCase")]
 pub struct Vote {
   actor: ObjectId<ApubPerson>,
-  to: [PublicUrl; 1],
+  to: Vec<Url>,
   pub(in crate::activities::voting) object: ObjectId<PostOrComment>,
   cc: [ObjectId<ApubCommunity>; 1],
   #[serde(rename = "type")]
@@ -80,7 +80,7 @@ impl Vote {
   ) -> Result<Vote, LemmyError> {
     Ok(Vote {
       actor: ObjectId::new(actor.actor_id()),
-      to: [PublicUrl::Public],
+      to: vec![public()],
       object: ObjectId::new(object.ap_id()),
       cc: [ObjectId::new(community.actor_id())],
       kind: kind.clone(),
@@ -118,6 +118,7 @@ impl ActivityHandler for Vote {
     context: &Data<LemmyContext>,
     request_counter: &mut i32,
   ) -> Result<(), LemmyError> {
+    verify_is_public(&self.to)?;
     verify_activity(self, &context.settings())?;
     verify_person_in_community(&self.actor, &self.cc[0], context, request_counter).await?;
     Ok(())
index dcaf551f16837a65667f2b19761faaefffaa69e7..a7e66d8a373ba306271e9f5388f64686345093d3 100644 (file)
@@ -32,7 +32,7 @@ use lemmy_db_schema::source::community::Community;
 use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
-use log::trace;
+use log::info;
 use serde::{Deserialize, Serialize};
 
 #[derive(Deserialize)]
@@ -78,7 +78,7 @@ pub async fn community_inbox(
   context: web::Data<LemmyContext>,
 ) -> Result<HttpResponse, LemmyError> {
   let unparsed = payload_to_string(payload).await?;
-  trace!("Received community inbox activity {}", unparsed);
+  info!("Received community inbox activity {}", unparsed);
   let activity = serde_json::from_str::<GroupInboxActivities>(&unparsed)?;
 
   receive_group_inbox(activity.clone(), request, &context).await?;
index b82a6d890ce83ff9d0507fe37bf4480562620bd7..fe44d5e3f04aab61b62f67395f4a9a32388f66bc 100644 (file)
@@ -27,7 +27,7 @@ use lemmy_apub_lib::{
 use lemmy_db_schema::{source::activity::Activity, DbPool};
 use lemmy_utils::{location_info, LemmyError};
 use lemmy_websocket::LemmyContext;
-use log::{info, trace};
+use log::info;
 use serde::{Deserialize, Serialize};
 use std::{fmt::Debug, io::Read};
 use url::Url;
@@ -54,7 +54,7 @@ pub async fn shared_inbox(
   context: web::Data<LemmyContext>,
 ) -> Result<HttpResponse, LemmyError> {
   let unparsed = payload_to_string(payload).await?;
-  trace!("Received shared inbox activity {}", unparsed);
+  info!("Received shared inbox activity {}", unparsed);
   let activity = serde_json::from_str::<SharedInboxActivities>(&unparsed)?;
   match activity {
     SharedInboxActivities::GroupInboxActivities(g) => {
index a7e94020e25cd80c5c8dbf380b8a7dc172bf8607..88ffa12033f776885df048784c478da842613d7f 100644 (file)
@@ -28,7 +28,7 @@ use lemmy_apub_lib::traits::{ActivityFields, ActivityHandler, ApubObject};
 use lemmy_db_schema::source::person::Person;
 use lemmy_utils::LemmyError;
 use lemmy_websocket::LemmyContext;
-use log::trace;
+use log::info;
 use serde::{Deserialize, Serialize};
 use url::Url;
 
@@ -79,7 +79,7 @@ pub async fn person_inbox(
   context: web::Data<LemmyContext>,
 ) -> Result<HttpResponse, LemmyError> {
   let unparsed = payload_to_string(payload).await?;
-  trace!("Received person inbox activity {}", unparsed);
+  info!("Received person inbox activity {}", unparsed);
   let activity = serde_json::from_str::<PersonInboxActivities>(&unparsed)?;
   receive_person_inbox(activity, request, &context).await
 }
index 2c9f65ffe8de1cefaf960ef78c5666ca4adcf63a..bd014c12bd9a6e7ac5ffb97e633ca21781bb4123 100644 (file)
 
 use serde::{Deserialize, Serialize};
 
-/// The identifier used to address activities to the public.
-///
-/// <https://www.w3.org/TR/activitypub/#public-addressing>
-#[derive(Debug, Clone, Deserialize, Serialize)]
-pub enum PublicUrl {
-  #[serde(rename = "https://www.w3.org/ns/activitystreams#Public")]
-  Public,
-}
-
 /// Media type for markdown text.
 ///
 /// <https://www.iana.org/assignments/media-types/media-types.xhtml>