diff --git a/crates/apub/src/activities/comment/create_or_update.rs b/crates/apub/src/activities/comment/create_or_update.rs index 24811ef0d..9ce172004 100644 --- a/crates/apub/src/activities/comment/create_or_update.rs +++ b/crates/apub/src/activities/comment/create_or_update.rs @@ -61,7 +61,7 @@ impl CreateOrUpdateComment { let maa = collect_non_local_mentions(comment, &community, context).await?; let create_or_update = CreateOrUpdateComment { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object: comment.to_apub(context.pool()).await?, cc: maa.ccs, @@ -85,7 +85,7 @@ impl ActivityHandler for CreateOrUpdateComment { request_counter: &mut i32, ) -> Result<(), LemmyError> { let community = extract_community(&self.cc, context, request_counter).await?; - let community_id = ObjectId::::new(community.actor_id()); + let community_id = ObjectId::new(community.actor_id()); verify_activity(self)?; verify_person_in_community(&self.actor, &community_id, context, request_counter).await?; diff --git a/crates/apub/src/activities/comment/mod.rs b/crates/apub/src/activities/comment/mod.rs index 0b5166bef..8f27e9bac 100644 --- a/crates/apub/src/activities/comment/mod.rs +++ b/crates/apub/src/activities/comment/mod.rs @@ -76,7 +76,7 @@ pub async fn collect_non_local_mentions( for mention in &mentions { // TODO should it be fetching it every time? if let Ok(actor_id) = fetch_webfinger_url(mention, context.client()).await { - let actor_id: ObjectId = ObjectId::::new(actor_id); + let actor_id: ObjectId = ObjectId::new(actor_id); debug!("mention actor_id: {}", actor_id); addressed_ccs.push(actor_id.to_owned().to_string().parse()?); diff --git a/crates/apub/src/activities/community/add_mod.rs b/crates/apub/src/activities/community/add_mod.rs index c2a2ff2d7..a066211f3 100644 --- a/crates/apub/src/activities/community/add_mod.rs +++ b/crates/apub/src/activities/community/add_mod.rs @@ -57,11 +57,11 @@ impl AddMod { ) -> Result<(), LemmyError> { let id = generate_activity_id(AddType::Add)?; let add = AddMod { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], - object: ObjectId::::new(added_mod.actor_id()), + object: ObjectId::new(added_mod.actor_id()), target: generate_moderators_url(&community.actor_id)?.into(), - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: AddType::Add, id: id.clone(), context: lemmy_context(), diff --git a/crates/apub/src/activities/community/announce.rs b/crates/apub/src/activities/community/announce.rs index 53ff05f0a..96797c8ff 100644 --- a/crates/apub/src/activities/community/announce.rs +++ b/crates/apub/src/activities/community/announce.rs @@ -79,7 +79,7 @@ impl AnnounceActivity { context: &LemmyContext, ) -> Result<(), LemmyError> { let announce = AnnounceActivity { - actor: ObjectId::::new(community.actor_id()), + actor: ObjectId::new(community.actor_id()), to: [PublicUrl::Public], object, cc: vec![community.followers_url()], diff --git a/crates/apub/src/activities/community/block_user.rs b/crates/apub/src/activities/community/block_user.rs index 4c7a09635..f7e81f97c 100644 --- a/crates/apub/src/activities/community/block_user.rs +++ b/crates/apub/src/activities/community/block_user.rs @@ -58,10 +58,10 @@ impl BlockUserFromCommunity { actor: &Person, ) -> Result { Ok(BlockUserFromCommunity { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], - object: ObjectId::::new(target.actor_id()), - cc: [ObjectId::::new(community.actor_id())], + object: ObjectId::new(target.actor_id()), + cc: [ObjectId::new(community.actor_id())], kind: BlockType::Block, id: generate_activity_id(BlockType::Block)?, context: lemmy_context(), diff --git a/crates/apub/src/activities/community/remove_mod.rs b/crates/apub/src/activities/community/remove_mod.rs index 2b6cdeb1a..4960076c1 100644 --- a/crates/apub/src/activities/community/remove_mod.rs +++ b/crates/apub/src/activities/community/remove_mod.rs @@ -59,13 +59,13 @@ impl RemoveMod { ) -> Result<(), LemmyError> { let id = generate_activity_id(RemoveType::Remove)?; let remove = RemoveMod { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], - object: ObjectId::::new(removed_mod.actor_id()), + object: ObjectId::new(removed_mod.actor_id()), target: Some(generate_moderators_url(&community.actor_id)?.into()), id: id.clone(), context: lemmy_context(), - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: RemoveType::Remove, unparsed: Default::default(), }; diff --git a/crates/apub/src/activities/community/undo_block_user.rs b/crates/apub/src/activities/community/undo_block_user.rs index db3c717e8..eec906821 100644 --- a/crates/apub/src/activities/community/undo_block_user.rs +++ b/crates/apub/src/activities/community/undo_block_user.rs @@ -56,10 +56,10 @@ impl UndoBlockUserFromCommunity { let id = generate_activity_id(UndoType::Undo)?; let undo = UndoBlockUserFromCommunity { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object: block, - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: UndoType::Undo, id: id.clone(), context: lemmy_context(), diff --git a/crates/apub/src/activities/community/update.rs b/crates/apub/src/activities/community/update.rs index b8f3b5f5b..a6da1c9f3 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -57,10 +57,10 @@ impl UpdateCommunity { ) -> Result<(), LemmyError> { let id = generate_activity_id(UpdateType::Update)?; let update = UpdateCommunity { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object: community.to_apub(context.pool()).await?, - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: UpdateType::Update, id: id.clone(), context: lemmy_context(), diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index 6aa6920ee..8e8bd942f 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -140,10 +140,10 @@ impl Delete { summary: Option, ) -> Result { Ok(Delete { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object: object_id, - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: DeleteType::Delete, summary, id: generate_activity_id(DeleteType::Delete)?, diff --git a/crates/apub/src/activities/deletion/mod.rs b/crates/apub/src/activities/deletion/mod.rs index 930ed6c0d..5843e5017 100644 --- a/crates/apub/src/activities/deletion/mod.rs +++ b/crates/apub/src/activities/deletion/mod.rs @@ -105,7 +105,7 @@ pub(in crate::activities) async fn verify_delete_activity( request_counter: &mut i32, ) -> Result<(), LemmyError> { let object = DeletableObjects::read_from_db(object, context).await?; - let actor = ObjectId::::new(activity.actor().clone()); + let actor = ObjectId::new(activity.actor().clone()); match object { DeletableObjects::Community(c) => { if c.local { @@ -114,7 +114,7 @@ pub(in crate::activities) async fn verify_delete_activity( verify_person_in_community(&actor, community_id, context, request_counter).await?; } // community deletion is always a mod (or admin) action - verify_mod_action(&actor, ObjectId::::new(c.actor_id()), context).await?; + verify_mod_action(&actor, ObjectId::new(c.actor_id()), context).await?; } DeletableObjects::Post(p) => { verify_delete_activity_post_or_comment( @@ -150,7 +150,7 @@ async fn verify_delete_activity_post_or_comment( context: &LemmyContext, request_counter: &mut i32, ) -> Result<(), LemmyError> { - let actor = ObjectId::::new(activity.actor().clone()); + let actor = ObjectId::new(activity.actor().clone()); verify_person_in_community(&actor, community_id, context, request_counter).await?; if is_mod_action { verify_mod_action(&actor, community_id.clone(), context).await?; diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index 8e46e969c..2dbbf9c46 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -110,10 +110,10 @@ impl UndoDelete { let id = generate_activity_id(UndoType::Undo)?; let undo = UndoDelete { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object, - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: UndoType::Undo, id: id.clone(), context: lemmy_context(), diff --git a/crates/apub/src/activities/following/accept.rs b/crates/apub/src/activities/following/accept.rs index a5556a614..a7472bc1c 100644 --- a/crates/apub/src/activities/following/accept.rs +++ b/crates/apub/src/activities/following/accept.rs @@ -57,8 +57,8 @@ impl AcceptFollowCommunity { .await??; let accept = AcceptFollowCommunity { - actor: ObjectId::::new(community.actor_id()), - to: ObjectId::::new(person.actor_id()), + actor: ObjectId::new(community.actor_id()), + to: ObjectId::new(person.actor_id()), object: follow, kind: AcceptType::Accept, id: generate_activity_id(AcceptType::Accept)?, diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index 556366d4d..8af3d3889 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -50,9 +50,9 @@ impl FollowCommunity { community: &Community, ) -> Result { Ok(FollowCommunity { - actor: ObjectId::::new(actor.actor_id()), - to: ObjectId::::new(community.actor_id()), - object: ObjectId::::new(community.actor_id()), + actor: ObjectId::new(actor.actor_id()), + to: ObjectId::new(community.actor_id()), + object: ObjectId::new(community.actor_id()), kind: FollowType::Follow, id: generate_activity_id(FollowType::Follow)?, context: lemmy_context(), diff --git a/crates/apub/src/activities/following/undo.rs b/crates/apub/src/activities/following/undo.rs index 64ff8ddb4..f35b3095f 100644 --- a/crates/apub/src/activities/following/undo.rs +++ b/crates/apub/src/activities/following/undo.rs @@ -51,8 +51,8 @@ impl UndoFollowCommunity { ) -> Result<(), LemmyError> { let object = FollowCommunity::new(actor, community)?; let undo = UndoFollowCommunity { - actor: ObjectId::::new(actor.actor_id()), - to: ObjectId::::new(community.actor_id()), + actor: ObjectId::new(actor.actor_id()), + to: ObjectId::new(community.actor_id()), object, kind: UndoType::Undo, id: generate_activity_id(UndoType::Undo)?, diff --git a/crates/apub/src/activities/mod.rs b/crates/apub/src/activities/mod.rs index 9eb0e5af0..3cfaca859 100644 --- a/crates/apub/src/activities/mod.rs +++ b/crates/apub/src/activities/mod.rs @@ -58,7 +58,7 @@ pub(crate) async fn extract_community( let mut cc_iter = cc.iter(); loop { if let Some(cid) = cc_iter.next() { - let cid = ObjectId::::new(cid.clone()); + let cid = ObjectId::new(cid.clone()); if let Ok(c) = cid.dereference(context, request_counter).await { break Ok(c); } diff --git a/crates/apub/src/activities/post/create_or_update.rs b/crates/apub/src/activities/post/create_or_update.rs index 073c9297d..8a48da5f8 100644 --- a/crates/apub/src/activities/post/create_or_update.rs +++ b/crates/apub/src/activities/post/create_or_update.rs @@ -61,10 +61,10 @@ impl CreateOrUpdatePost { let id = generate_activity_id(kind.clone())?; let create_or_update = CreateOrUpdatePost { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object: post.to_apub(context.pool()).await?, - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind, id: id.clone(), context: lemmy_context(), diff --git a/crates/apub/src/activities/private_message/create_or_update.rs b/crates/apub/src/activities/private_message/create_or_update.rs index 9def0866e..83f4824b1 100644 --- a/crates/apub/src/activities/private_message/create_or_update.rs +++ b/crates/apub/src/activities/private_message/create_or_update.rs @@ -46,8 +46,8 @@ impl CreateOrUpdatePrivateMessage { let create_or_update = CreateOrUpdatePrivateMessage { context: lemmy_context(), id: id.clone(), - actor: ObjectId::::new(actor.actor_id()), - to: ObjectId::::new(recipient.actor_id()), + actor: ObjectId::new(actor.actor_id()), + to: ObjectId::new(recipient.actor_id()), object: private_message.to_apub(context.pool()).await?, kind, unparsed: Default::default(), diff --git a/crates/apub/src/activities/private_message/delete.rs b/crates/apub/src/activities/private_message/delete.rs index 9881fa4d9..82aad3177 100644 --- a/crates/apub/src/activities/private_message/delete.rs +++ b/crates/apub/src/activities/private_message/delete.rs @@ -41,8 +41,8 @@ impl DeletePrivateMessage { pm: &PrivateMessage, ) -> Result { Ok(DeletePrivateMessage { - actor: ObjectId::::new(actor.actor_id()), - to: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), + to: ObjectId::new(actor.actor_id()), object: pm.ap_id.clone().into(), kind: DeleteType::Delete, id: generate_activity_id(DeleteType::Delete)?, diff --git a/crates/apub/src/activities/private_message/undo_delete.rs b/crates/apub/src/activities/private_message/undo_delete.rs index 46c3cfbfa..2dc9d7242 100644 --- a/crates/apub/src/activities/private_message/undo_delete.rs +++ b/crates/apub/src/activities/private_message/undo_delete.rs @@ -53,8 +53,8 @@ impl UndoDeletePrivateMessage { let object = DeletePrivateMessage::new(actor, pm)?; let id = generate_activity_id(UndoType::Undo)?; let undo = UndoDeletePrivateMessage { - actor: ObjectId::::new(actor.actor_id()), - to: ObjectId::::new(recipient.actor_id()), + actor: ObjectId::new(actor.actor_id()), + to: ObjectId::new(recipient.actor_id()), object, kind: UndoType::Undo, id: id.clone(), diff --git a/crates/apub/src/activities/voting/undo_vote.rs b/crates/apub/src/activities/voting/undo_vote.rs index 85d8ee81f..e11d29602 100644 --- a/crates/apub/src/activities/voting/undo_vote.rs +++ b/crates/apub/src/activities/voting/undo_vote.rs @@ -67,10 +67,10 @@ impl UndoVote { let object = Vote::new(object, actor, &community, kind.clone())?; let id = generate_activity_id(UndoType::Undo)?; let undo_vote = UndoVote { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], object, - cc: [ObjectId::::new(community.actor_id())], + cc: [ObjectId::new(community.actor_id())], kind: UndoType::Undo, id: id.clone(), context: lemmy_context(), diff --git a/crates/apub/src/activities/voting/vote.rs b/crates/apub/src/activities/voting/vote.rs index c6cdee935..69a9c3ba9 100644 --- a/crates/apub/src/activities/voting/vote.rs +++ b/crates/apub/src/activities/voting/vote.rs @@ -79,10 +79,10 @@ impl Vote { kind: VoteType, ) -> Result { Ok(Vote { - actor: ObjectId::::new(actor.actor_id()), + actor: ObjectId::new(actor.actor_id()), to: [PublicUrl::Public], - object: ObjectId::::new(object.ap_id()), - cc: [ObjectId::::new(community.actor_id())], + object: ObjectId::new(object.ap_id()), + cc: [ObjectId::new(community.actor_id())], kind: kind.clone(), id: generate_activity_id(kind)?, context: lemmy_context(), diff --git a/crates/apub/src/fetcher/community.rs b/crates/apub/src/fetcher/community.rs index 229f322bc..99dd3f85e 100644 --- a/crates/apub/src/fetcher/community.rs +++ b/crates/apub/src/fetcher/community.rs @@ -45,8 +45,8 @@ pub(crate) async fn update_community_mods( // Add new mods to database which have been added to moderators collection for mod_id in new_moderators { - let mod_id = ObjectId::::new::(mod_id); - let mod_user = mod_id.dereference(context, request_counter).await?; + let mod_id = ObjectId::new(mod_id); + let mod_user: Person = mod_id.dereference(context, request_counter).await?; if !current_moderators .clone() diff --git a/crates/apub/src/fetcher/mod.rs b/crates/apub/src/fetcher/mod.rs index c9e7c47f3..0ef72b25b 100644 --- a/crates/apub/src/fetcher/mod.rs +++ b/crates/apub/src/fetcher/mod.rs @@ -28,12 +28,12 @@ pub(crate) async fn get_or_fetch_and_upsert_actor( context: &LemmyContext, recursion_counter: &mut i32, ) -> Result, LemmyError> { - let community_id: ObjectId = ObjectId::::new(apub_id.clone()); + let community_id = ObjectId::::new(apub_id.clone()); let community = community_id.dereference(context, recursion_counter).await; let actor: Box = match community { Ok(c) => Box::new(c), Err(_) => { - let person_id: ObjectId = ObjectId::::new(apub_id); + let person_id = ObjectId::new(apub_id); let person: Person = person_id.dereference(context, recursion_counter).await?; Box::new(person) } diff --git a/crates/apub/src/fetcher/object_id.rs b/crates/apub/src/fetcher/object_id.rs index b88b804de..7b3c535fa 100644 --- a/crates/apub/src/fetcher/object_id.rs +++ b/crates/apub/src/fetcher/object_id.rs @@ -34,13 +34,11 @@ where Kind: FromApub + ApubObject + DeletableApubObject + Send + 'static, for<'de> ::ApubType: serde::Deserialize<'de>, { - pub fn new(url: T) -> ObjectId + pub fn new(url: T) -> Self where T: Into, - K: FromApub + ApubObject + DeletableApubObject + Send + 'static, - for<'de> ::ApubType: serde::Deserialize<'de>, { - ObjectId(url.into(), PhantomData::) + ObjectId(url.into(), PhantomData::) } pub fn inner(&self) -> &Url { diff --git a/crates/apub/src/fetcher/search.rs b/crates/apub/src/fetcher/search.rs index 46b1bd8fb..6a3cc14f0 100644 --- a/crates/apub/src/fetcher/search.rs +++ b/crates/apub/src/fetcher/search.rs @@ -55,7 +55,7 @@ pub async fn search_by_apub_id( }; let request_counter = &mut 0; - ObjectId::::new(query_url) + ObjectId::new(query_url) .dereference(context, request_counter) .await } diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 1e5a3fa1e..f33448710 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -82,14 +82,14 @@ impl Note { CommentInReplyToMigration::Old(in_reply_to) => { // This post, or the parent comment might not yet exist on this server yet, fetch them. let post_id = in_reply_to.get(0).context(location_info!())?; - let post_id = ObjectId::::new(post_id.clone()); + let post_id = ObjectId::new(post_id.clone()); let post = Box::pin(post_id.dereference(context, request_counter)).await?; // The 2nd item, if it exists, is the parent comment apub_id // Nested comments will automatically get fetched recursively let parent_id: Option = match in_reply_to.get(1) { Some(comment_id) => { - let comment_id: ObjectId = ObjectId::::new(comment_id.clone()); + let comment_id = ObjectId::::new(comment_id.clone()); let parent_comment = Box::pin(comment_id.dereference(context, request_counter)).await?; Some(parent_comment.id) @@ -137,7 +137,7 @@ impl Note { verify_domains_match(self.attributed_to.inner(), &self.id)?; verify_person_in_community( &self.attributed_to, - &ObjectId::::new(community.actor_id()), + &ObjectId::new(community.actor_id()), context, request_counter, ) @@ -171,7 +171,7 @@ impl ToApub for Comment { context: lemmy_context(), r#type: NoteType::Note, id: self.ap_id.to_owned().into_inner(), - attributed_to: ObjectId::::new(creator.actor_id), + attributed_to: ObjectId::new(creator.actor_id), to: PublicUrl::Public, content: self.content.clone(), media_type: MediaTypeHtml::Html, diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 389eb3614..341b428b6 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -104,7 +104,7 @@ impl Page { verify_domains_match(self.attributed_to.inner(), &self.id)?; verify_person_in_community( &self.attributed_to, - &ObjectId::::new(community.actor_id()), + &ObjectId::new(community.actor_id()), context, request_counter, ) @@ -137,7 +137,7 @@ impl ToApub for Post { context: lemmy_context(), r#type: PageType::Page, id: self.ap_id.clone().into(), - attributed_to: ObjectId::::new(creator.actor_id), + attributed_to: ObjectId::new(creator.actor_id), to: [community.actor_id.into(), public()], name: self.name.clone(), content: self.body.as_ref().map(|b| markdown_to_html(b)), diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index cff0f5cc9..9bc917a95 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -87,8 +87,8 @@ impl ToApub for PrivateMessage { context: lemmy_context(), r#type: NoteType::Note, id: self.ap_id.clone().into(), - attributed_to: ObjectId::::new(creator.actor_id), - to: ObjectId::::new(recipient.actor_id), + attributed_to: ObjectId::new(creator.actor_id), + to: ObjectId::new(recipient.actor_id), content: self.content.clone(), media_type: MediaTypeHtml::Html, source: Source {