diff --git a/api_tests/src/comment.spec.ts b/api_tests/src/comment.spec.ts index 7ded27993..2915d2612 100644 --- a/api_tests/src/comment.spec.ts +++ b/api_tests/src/comment.spec.ts @@ -389,7 +389,6 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde test('Report a comment', async () => { let betaCommunity = (await resolveBetaCommunity(beta)).community; - console.log(betaCommunity); let postRes = (await createPost(beta, betaCommunity.community.id)).post_view.post; expect(postRes).toBeDefined(); let commentRes = (await createComment(beta, postRes.id)).comment_view.comment; diff --git a/crates/apub/src/activities/comment/create_or_update.rs b/crates/apub/src/activities/comment/create_or_update.rs index 43bde2465..c4591c7c8 100644 --- a/crates/apub/src/activities/comment/create_or_update.rs +++ b/crates/apub/src/activities/comment/create_or_update.rs @@ -11,7 +11,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{ comment::{ApubComment, Note}, community::ApubCommunity, @@ -23,6 +22,7 @@ use lemmy_api_common::{blocking, check_post_deleted_or_removed}; use lemmy_apub_lib::{ data::Data, traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub}, + values::PublicUrl, verify::verify_domains_match, }; use lemmy_db_schema::{ @@ -38,7 +38,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct CreateOrUpdateComment { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: Note, cc: Vec, tag: Vec, @@ -76,7 +76,7 @@ impl CreateOrUpdateComment { let create_or_update = CreateOrUpdateComment { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + 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 a5b597f52..e1cf03e0d 100644 --- a/crates/apub/src/activities/community/add_mod.rs +++ b/crates/apub/src/activities/community/add_mod.rs @@ -10,7 +10,6 @@ use crate::{ context::lemmy_context, fetcher::object_id::ObjectId, generate_moderators_url, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, }; use activitystreams::{ @@ -23,6 +22,7 @@ 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 +37,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct AddMod { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: ObjectId, target: Url, cc: [ObjectId; 1], @@ -63,7 +63,7 @@ impl AddMod { )?; let add = AddMod { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: ObjectId::new(added_mod.actor_id()), target: generate_moderators_url(&community.actor_id)?.into(), cc: [ObjectId::new(community.actor_id())], diff --git a/crates/apub/src/activities/community/announce.rs b/crates/apub/src/activities/community/announce.rs index 5e8bb5203..f3dc72c56 100644 --- a/crates/apub/src/activities/community/announce.rs +++ b/crates/apub/src/activities/community/announce.rs @@ -20,7 +20,6 @@ use crate::{ fetcher::object_id::ObjectId, http::is_activity_already_known, insert_activity, - migrations::PublicUrlMigration, objects::community::ApubCommunity, send_lemmy_activity, CommunityType, @@ -34,6 +33,7 @@ use activitystreams::{ use lemmy_apub_lib::{ data::Data, traits::{ActivityFields, ActivityHandler, ActorType}, + values::PublicUrl, }; use lemmy_utils::LemmyError; use lemmy_websocket::LemmyContext; @@ -61,7 +61,7 @@ pub enum AnnouncableActivities { #[serde(rename_all = "camelCase")] pub struct AnnounceActivity { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: AnnouncableActivities, cc: Vec, #[serde(rename = "type")] @@ -82,7 +82,7 @@ impl AnnounceActivity { ) -> Result<(), LemmyError> { let announce = AnnounceActivity { actor: ObjectId::new(community.actor_id()), - to: PublicUrlMigration::create(), + 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 d8e131fc3..a1c76c23b 100644 --- a/crates/apub/src/activities/community/block_user.rs +++ b/crates/apub/src/activities/community/block_user.rs @@ -8,7 +8,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, }; use activitystreams::{ @@ -21,6 +20,7 @@ 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 +40,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct BlockUserFromCommunity { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], pub(in crate::activities::community) object: ObjectId, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -61,7 +61,7 @@ impl BlockUserFromCommunity { ) -> Result { Ok(BlockUserFromCommunity { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: ObjectId::new(target.actor_id()), cc: [ObjectId::new(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 7d98f4a2d..9f4c9ae62 100644 --- a/crates/apub/src/activities/community/remove_mod.rs +++ b/crates/apub/src/activities/community/remove_mod.rs @@ -10,7 +10,6 @@ use crate::{ context::lemmy_context, fetcher::object_id::ObjectId, generate_moderators_url, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, }; use activitystreams::{ @@ -23,6 +22,7 @@ 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 +37,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct RemoveMod { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], pub(in crate::activities) object: ObjectId, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -64,7 +64,7 @@ impl RemoveMod { )?; let remove = RemoveMod { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: ObjectId::new(removed_mod.actor_id()), target: 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 6b405cf48..1614de672 100644 --- a/crates/apub/src/activities/community/undo_block_user.rs +++ b/crates/apub/src/activities/community/undo_block_user.rs @@ -12,7 +12,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, }; use activitystreams::{ @@ -25,6 +24,7 @@ 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 +39,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoBlockUserFromCommunity { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: BlockUserFromCommunity, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -66,7 +66,7 @@ impl UndoBlockUserFromCommunity { )?; let undo = UndoBlockUserFromCommunity { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: block, cc: [ObjectId::new(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 3a7b44fee..1120bd8bb 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -8,7 +8,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{ community::{ApubCommunity, Group}, person::ApubPerson, @@ -24,6 +23,7 @@ use lemmy_api_common::blocking; use lemmy_apub_lib::{ data::Data, traits::{ActivityFields, ActivityHandler, ActorType, ToApub}, + values::PublicUrl, }; use lemmy_db_schema::{ source::community::{Community, CommunityForm}, @@ -40,7 +40,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UpdateCommunity { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], // TODO: would be nice to use a separate struct here, which only contains the fields updated here object: Group, cc: [ObjectId; 1], @@ -65,7 +65,7 @@ impl UpdateCommunity { )?; let update = UpdateCommunity { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: community.to_apub(context.pool()).await?, cc: [ObjectId::new(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 acfc1ba7e..02df7dc38 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -12,7 +12,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, }; use activitystreams::{ @@ -26,6 +25,7 @@ use lemmy_api_common::blocking; use lemmy_apub_lib::{ data::Data, traits::{ActivityFields, ActivityHandler, ActorType}, + values::PublicUrl, }; use lemmy_db_schema::{ source::{ @@ -66,7 +66,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct Delete { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], pub(in crate::activities::deletion) object: Url, pub(in crate::activities::deletion) cc: [ObjectId; 1], #[serde(rename = "type")] @@ -144,7 +144,7 @@ impl Delete { ) -> Result { Ok(Delete { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: object_id, cc: [ObjectId::new(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 2527a9717..327bf86c0 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -13,7 +13,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, }; use activitystreams::{ @@ -27,6 +26,7 @@ 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 +42,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoDelete { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: Delete, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -117,7 +117,7 @@ impl UndoDelete { )?; let undo = UndoDelete { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object, cc: [ObjectId::new(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 cda78ce1e..cc7ef5c97 100644 --- a/crates/apub/src/activities/post/create_or_update.rs +++ b/crates/apub/src/activities/post/create_or_update.rs @@ -10,7 +10,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{ community::ApubCommunity, person::ApubPerson, @@ -23,6 +22,7 @@ use lemmy_api_common::blocking; use lemmy_apub_lib::{ data::Data, traits::{ActivityFields, ActivityHandler, ActorType, FromApub, ToApub}, + 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, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: Page, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -67,7 +67,7 @@ impl CreateOrUpdatePost { )?; let create_or_update = CreateOrUpdatePost { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: post.to_apub(context.pool()).await?, cc: [ObjectId::new(community.actor_id())], kind, diff --git a/crates/apub/src/activities/voting/undo_vote.rs b/crates/apub/src/activities/voting/undo_vote.rs index fa7a11195..d72b5245d 100644 --- a/crates/apub/src/activities/voting/undo_vote.rs +++ b/crates/apub/src/activities/voting/undo_vote.rs @@ -12,7 +12,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, PostOrComment, }; @@ -26,6 +25,7 @@ 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 +39,7 @@ use url::Url; #[serde(rename_all = "camelCase")] pub struct UndoVote { actor: ObjectId, - to: PublicUrlMigration, + to: [PublicUrl; 1], object: Vote, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -72,7 +72,7 @@ impl UndoVote { )?; let undo_vote = UndoVote { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object, cc: [ObjectId::new(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 847ffbd4c..5d4c9066e 100644 --- a/crates/apub/src/activities/voting/vote.rs +++ b/crates/apub/src/activities/voting/vote.rs @@ -8,7 +8,6 @@ use crate::{ }, context::lemmy_context, fetcher::object_id::ObjectId, - migrations::PublicUrlMigration, objects::{community::ApubCommunity, person::ApubPerson}, PostOrComment, }; @@ -18,6 +17,7 @@ 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, - to: PublicUrlMigration, + to: [PublicUrl; 1], pub(in crate::activities::voting) object: ObjectId, cc: [ObjectId; 1], #[serde(rename = "type")] @@ -80,7 +80,7 @@ impl Vote { ) -> Result { Ok(Vote { actor: ObjectId::new(actor.actor_id()), - to: PublicUrlMigration::create(), + to: [PublicUrl::Public], object: ObjectId::new(object.ap_id()), cc: [ObjectId::new(community.actor_id())], kind: kind.clone(), diff --git a/crates/apub/src/migrations.rs b/crates/apub/src/migrations.rs index b75f617ba..8b1378917 100644 --- a/crates/apub/src/migrations.rs +++ b/crates/apub/src/migrations.rs @@ -1,20 +1 @@ -use lemmy_apub_lib::values::PublicUrl; -use serde::{Deserialize, Serialize}; -/// Migrate value of field `to` from single value to vec. -/// -/// v0.14: send as single value, accept both -/// v0.15: send as vec, accept both -/// v0.16: send and accept only vec -#[derive(Serialize, Deserialize, Debug, Clone)] -#[serde(untagged)] -pub enum PublicUrlMigration { - Old(PublicUrl), - New([PublicUrl; 1]), -} - -impl PublicUrlMigration { - pub(crate) fn create() -> PublicUrlMigration { - PublicUrlMigration::Old(PublicUrl::Public) - } -}