From 2822f5a12608a30824e89ce3d82c248b51b2dca9 Mon Sep 17 00:00:00 2001 From: Nutomic Date: Sat, 28 Aug 2021 01:33:38 +0000 Subject: [PATCH] Change public activities to field to array (#1739) --- crates/apub/src/activities/comment/create_or_update.rs | 4 ++-- crates/apub/src/activities/community/add_mod.rs | 4 ++-- crates/apub/src/activities/community/announce.rs | 4 ++-- crates/apub/src/activities/community/block_user.rs | 4 ++-- crates/apub/src/activities/community/remove_mod.rs | 4 ++-- crates/apub/src/activities/community/undo_block_user.rs | 4 ++-- crates/apub/src/activities/community/update.rs | 4 ++-- crates/apub/src/activities/deletion/delete.rs | 4 ++-- crates/apub/src/activities/deletion/undo_delete.rs | 4 ++-- crates/apub/src/activities/post/create_or_update.rs | 4 ++-- crates/apub/src/activities/undo_remove.rs | 2 +- crates/apub/src/activities/voting/undo_vote.rs | 4 ++-- crates/apub/src/activities/voting/vote.rs | 4 ++-- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/crates/apub/src/activities/comment/create_or_update.rs b/crates/apub/src/activities/comment/create_or_update.rs index 7f83d78f..e6876e77 100644 --- a/crates/apub/src/activities/comment/create_or_update.rs +++ b/crates/apub/src/activities/comment/create_or_update.rs @@ -27,7 +27,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct CreateOrUpdateComment { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: Note, cc: Vec, tag: Vec, @@ -61,7 +61,7 @@ impl CreateOrUpdateComment { let create_or_update = CreateOrUpdateComment { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: comment.to_apub(context.pool()).await?, cc: maa.ccs, tag: maa.tags, diff --git a/crates/apub/src/activities/community/add_mod.rs b/crates/apub/src/activities/community/add_mod.rs index f83f1463..56013d4a 100644 --- a/crates/apub/src/activities/community/add_mod.rs +++ b/crates/apub/src/activities/community/add_mod.rs @@ -35,7 +35,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct AddMod { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: Url, target: Url, cc: [Url; 1], @@ -58,7 +58,7 @@ impl AddMod { let id = generate_activity_id(AddType::Add)?; let add = AddMod { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: added_mod.actor_id(), target: generate_moderators_url(&community.actor_id)?.into(), cc: [community.actor_id()], diff --git a/crates/apub/src/activities/community/announce.rs b/crates/apub/src/activities/community/announce.rs index e7d917b7..d16345cc 100644 --- a/crates/apub/src/activities/community/announce.rs +++ b/crates/apub/src/activities/community/announce.rs @@ -58,7 +58,7 @@ pub enum AnnouncableActivities { #[serde(rename_all = "camelCase")] pub struct AnnounceActivity { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: AnnouncableActivities, cc: Vec, #[serde(rename = "type")] @@ -79,7 +79,7 @@ impl AnnounceActivity { ) -> Result<(), LemmyError> { let announce = AnnounceActivity { actor: community.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object, cc: vec![community.followers_url()], kind: AnnounceType::Announce, diff --git a/crates/apub/src/activities/community/block_user.rs b/crates/apub/src/activities/community/block_user.rs index d31077df..777faf9a 100644 --- a/crates/apub/src/activities/community/block_user.rs +++ b/crates/apub/src/activities/community/block_user.rs @@ -39,7 +39,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct BlockUserFromCommunity { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], pub(in crate::activities::community) object: Url, cc: [Url; 1], #[serde(rename = "type")] @@ -59,7 +59,7 @@ impl BlockUserFromCommunity { ) -> Result { Ok(BlockUserFromCommunity { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: target.actor_id(), cc: [community.actor_id()], kind: BlockType::Block, diff --git a/crates/apub/src/activities/community/remove_mod.rs b/crates/apub/src/activities/community/remove_mod.rs index 2d4eba56..c7175567 100644 --- a/crates/apub/src/activities/community/remove_mod.rs +++ b/crates/apub/src/activities/community/remove_mod.rs @@ -36,7 +36,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct RemoveMod { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], pub(in crate::activities) object: Url, cc: [Url; 1], #[serde(rename = "type")] @@ -60,7 +60,7 @@ impl RemoveMod { let id = generate_activity_id(RemoveType::Remove)?; let remove = RemoveMod { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: removed_mod.actor_id(), target: Some(generate_moderators_url(&community.actor_id)?.into()), id: id.clone(), diff --git a/crates/apub/src/activities/community/undo_block_user.rs b/crates/apub/src/activities/community/undo_block_user.rs index 0a9665af..9c12dd3a 100644 --- a/crates/apub/src/activities/community/undo_block_user.rs +++ b/crates/apub/src/activities/community/undo_block_user.rs @@ -33,7 +33,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoBlockUserFromCommunity { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: BlockUserFromCommunity, cc: [Url; 1], #[serde(rename = "type")] @@ -57,7 +57,7 @@ impl UndoBlockUserFromCommunity { let id = generate_activity_id(UndoType::Undo)?; let undo = UndoBlockUserFromCommunity { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: block, cc: [community.actor_id()], kind: UndoType::Undo, diff --git a/crates/apub/src/activities/community/update.rs b/crates/apub/src/activities/community/update.rs index 7539464d..88b9a62a 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -35,7 +35,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UpdateCommunity { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], // TODO: would be nice to use a separate struct here, which only contains the fields updated here object: Group, cc: [Url; 1], @@ -57,7 +57,7 @@ impl UpdateCommunity { let id = generate_activity_id(UpdateType::Update)?; let update = UpdateCommunity { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: community.to_apub(context.pool()).await?, cc: [community.actor_id()], kind: UpdateType::Update, diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index 45567288..cb1fdbd9 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -63,7 +63,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct Delete { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], pub(in crate::activities::deletion) object: Url, pub(in crate::activities::deletion) cc: [Url; 1], #[serde(rename = "type")] @@ -139,7 +139,7 @@ impl Delete { ) -> Result { Ok(Delete { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: object_id, cc: [community.actor_id()], kind: DeleteType::Delete, diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index 35369d44..bec7d76c 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -39,7 +39,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoDelete { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: Delete, cc: [Url; 1], #[serde(rename = "type")] @@ -110,7 +110,7 @@ impl UndoDelete { let id = generate_activity_id(UndoType::Undo)?; let undo = UndoDelete { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object, cc: [community.actor_id()], kind: UndoType::Undo, diff --git a/crates/apub/src/activities/post/create_or_update.rs b/crates/apub/src/activities/post/create_or_update.rs index c1b0703d..eff56ce2 100644 --- a/crates/apub/src/activities/post/create_or_update.rs +++ b/crates/apub/src/activities/post/create_or_update.rs @@ -35,7 +35,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct CreateOrUpdatePost { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: Page, cc: [Url; 1], #[serde(rename = "type")] @@ -63,7 +63,7 @@ impl CreateOrUpdatePost { let id = generate_activity_id(kind.clone())?; let create_or_update = CreateOrUpdatePost { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: post.to_apub(context.pool()).await?, cc: [community.actor_id()], kind, diff --git a/crates/apub/src/activities/undo_remove.rs b/crates/apub/src/activities/undo_remove.rs index 03b2f888..9720c06f 100644 --- a/crates/apub/src/activities/undo_remove.rs +++ b/crates/apub/src/activities/undo_remove.rs @@ -19,7 +19,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoRemovePostCommentOrCommunity { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], // Note, there is no such thing as Undo/Remove/Mod, so we ignore that object: RemoveMod, cc: [Url; 1], diff --git a/crates/apub/src/activities/voting/undo_vote.rs b/crates/apub/src/activities/voting/undo_vote.rs index 6e18b3cb..0f0eb1ff 100644 --- a/crates/apub/src/activities/voting/undo_vote.rs +++ b/crates/apub/src/activities/voting/undo_vote.rs @@ -42,7 +42,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoVote { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], object: Vote, cc: [Url; 1], #[serde(rename = "type")] @@ -71,7 +71,7 @@ impl UndoVote { let id = generate_activity_id(UndoType::Undo)?; let undo_vote = UndoVote { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object, cc: [community.actor_id()], kind: UndoType::Undo, diff --git a/crates/apub/src/activities/voting/vote.rs b/crates/apub/src/activities/voting/vote.rs index cd7d04c5..95d09961 100644 --- a/crates/apub/src/activities/voting/vote.rs +++ b/crates/apub/src/activities/voting/vote.rs @@ -62,7 +62,7 @@ impl From<&VoteType> for i16 { #[serde(rename_all = "camelCase")] pub struct Vote { actor: Url, - to: PublicUrl, + to: [PublicUrl; 1], pub(in crate::activities::voting) object: Url, cc: [Url; 1], #[serde(rename = "type")] @@ -83,7 +83,7 @@ impl Vote { ) -> Result { Ok(Vote { actor: actor.actor_id(), - to: PublicUrl::Public, + to: [PublicUrl::Public], object: object.ap_id(), cc: [community.actor_id()], kind: kind.clone(), -- 2.44.1