From d2dd4425634b54ef105aab44f1c37cc10a32491e Mon Sep 17 00:00:00 2001 From: dull b Date: Mon, 24 Jul 2023 19:04:30 +0000 Subject: [PATCH] Use non-borrowed forms --- crates/api/src/comment/distinguish.rs | 2 +- crates/api/src/community/add_mod.rs | 2 +- crates/api/src/community/ban.rs | 6 +- crates/api/src/community/transfer.rs | 2 +- crates/api/src/local_user/add_admin.rs | 2 +- crates/api/src/local_user/ban_person.rs | 2 +- .../notifications/mark_mention_read.rs | 2 +- .../notifications/mark_reply_read.rs | 2 +- crates/api/src/local_user/verify_email.rs | 2 +- crates/api/src/post/feature.rs | 2 +- crates/api/src/post/lock.rs | 2 +- crates/api/src/site/leave_admin.rs | 2 +- crates/api/src/site/purge/comment.rs | 2 +- crates/api/src/site/purge/community.rs | 2 +- crates/api/src/site/purge/person.rs | 2 +- crates/api/src/site/purge/post.rs | 2 +- crates/api_common/src/utils.rs | 2 +- crates/api_crud/src/comment/create.rs | 4 +- crates/api_crud/src/comment/remove.rs | 2 +- crates/api_crud/src/comment/update.rs | 2 +- crates/api_crud/src/community/remove.rs | 2 +- crates/api_crud/src/post/remove.rs | 2 +- crates/api_crud/src/user/create.rs | 2 +- .../apub/src/activities/block/block_user.rs | 6 +- .../src/activities/block/undo_block_user.rs | 6 +- .../activities/community/collection_add.rs | 6 +- .../activities/community/collection_remove.rs | 6 +- .../src/activities/community/lock_page.rs | 4 +- crates/apub/src/activities/deletion/delete.rs | 6 +- .../src/activities/deletion/undo_delete.rs | 6 +- .../apub/src/activities/following/follow.rs | 4 +- .../src/activities/following/undo_follow.rs | 4 +- crates/apub/src/objects/comment.rs | 2 +- crates/apub/src/objects/community.rs | 4 +- crates/apub/src/objects/person.rs | 2 +- crates/apub/src/objects/post.rs | 6 +- crates/apub/src/objects/private_message.rs | 2 +- crates/db_schema/src/impls/captcha_answer.rs | 4 +- crates/db_schema/src/impls/comment.rs | 10 ++-- crates/db_schema/src/impls/comment_reply.rs | 4 +- crates/db_schema/src/impls/comment_report.rs | 2 +- crates/db_schema/src/impls/community.rs | 20 +++---- crates/db_schema/src/impls/community_block.rs | 4 +- crates/db_schema/src/impls/local_user.rs | 4 +- crates/db_schema/src/impls/moderator.rs | 60 +++++++++---------- .../src/impls/password_reset_request.rs | 6 +- crates/db_schema/src/impls/person.rs | 8 +-- crates/db_schema/src/impls/person_block.rs | 7 +-- crates/db_schema/src/impls/person_mention.rs | 4 +- crates/db_schema/src/impls/post.rs | 14 ++--- crates/db_schema/src/impls/post_report.rs | 2 +- crates/db_schema/src/impls/private_message.rs | 4 +- .../src/impls/private_message_report.rs | 2 +- .../src/impls/registration_application.rs | 4 +- crates/db_schema/src/impls/site.rs | 4 +- crates/db_schema/src/traits.rs | 32 +++++----- src/code_migrations.rs | 8 +-- 57 files changed, 158 insertions(+), 161 deletions(-) diff --git a/crates/api/src/comment/distinguish.rs b/crates/api/src/comment/distinguish.rs index 47c23d3d2..a694bbc4b 100644 --- a/crates/api/src/comment/distinguish.rs +++ b/crates/api/src/comment/distinguish.rs @@ -44,7 +44,7 @@ impl Perform for DistinguishComment { let form = CommentUpdateForm::builder() .distinguished(Some(data.distinguished)) .build(); - Comment::update(&mut context.pool(), comment_id, &form) + Comment::update(&mut context.pool(), comment_id, form) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; diff --git a/crates/api/src/community/add_mod.rs b/crates/api/src/community/add_mod.rs index 086207775..43dd948e3 100644 --- a/crates/api/src/community/add_mod.rs +++ b/crates/api/src/community/add_mod.rs @@ -59,7 +59,7 @@ impl Perform for AddModToCommunity { removed: Some(!data.added), }; - ModAddCommunity::create(&mut context.pool(), &form).await?; + ModAddCommunity::create(&mut context.pool(), form).await?; // Note: in case a remote mod is added, this returns the old moderators list, it will only get // updated once we receive an activity from the community (like `Announce/Add/Moderator`) diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 33f6ef833..2b54aac5e 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -51,7 +51,7 @@ impl Perform for BanFromCommunity { }; if data.ban { - CommunityPersonBan::ban(&mut context.pool(), &community_user_ban_form) + CommunityPersonBan::ban(&mut context.pool(), community_user_ban_form) .await .with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?; @@ -66,7 +66,7 @@ impl Perform for BanFromCommunity { .await .ok(); } else { - CommunityPersonBan::unban(&mut context.pool(), &community_user_ban_form) + CommunityPersonBan::unban(&mut context.pool(), community_user_ban_form) .await .with_lemmy_type(LemmyErrorType::CommunityUserAlreadyBanned)?; } @@ -86,7 +86,7 @@ impl Perform for BanFromCommunity { expires, }; - ModBanFromCommunity::create(&mut context.pool(), &form).await?; + ModBanFromCommunity::create(&mut context.pool(), form).await?; let person_id = data.person_id; let person_view = PersonView::read(&mut context.pool(), person_id).await?; diff --git a/crates/api/src/community/transfer.rs b/crates/api/src/community/transfer.rs index 2b6579c4d..5630e5e15 100644 --- a/crates/api/src/community/transfer.rs +++ b/crates/api/src/community/transfer.rs @@ -79,7 +79,7 @@ impl Perform for TransferCommunity { community_id: data.community_id, }; - ModTransferCommunity::create(&mut context.pool(), &form).await?; + ModTransferCommunity::create(&mut context.pool(), form).await?; let community_id = data.community_id; let person_id = local_user_view.person.id; diff --git a/crates/api/src/local_user/add_admin.rs b/crates/api/src/local_user/add_admin.rs index 0b478ea92..82baa87b1 100644 --- a/crates/api/src/local_user/add_admin.rs +++ b/crates/api/src/local_user/add_admin.rs @@ -44,7 +44,7 @@ impl Perform for AddAdmin { removed: Some(!data.added), }; - ModAdd::create(&mut context.pool(), &form).await?; + ModAdd::create(&mut context.pool(), form).await?; let admins = PersonView::admins(&mut context.pool()).await?; diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index 83768bc23..aa3fe1871 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -68,7 +68,7 @@ impl Perform for BanPerson { expires, }; - ModBan::create(&mut context.pool(), &form).await?; + ModBan::create(&mut context.pool(), form).await?; let person_id = data.person_id; let person_view = PersonView::read(&mut context.pool(), person_id).await?; diff --git a/crates/api/src/local_user/notifications/mark_mention_read.rs b/crates/api/src/local_user/notifications/mark_mention_read.rs index 35feea645..e77c56b62 100644 --- a/crates/api/src/local_user/notifications/mark_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_mention_read.rs @@ -36,7 +36,7 @@ impl Perform for MarkPersonMentionAsRead { PersonMention::update( &mut context.pool(), person_mention_id, - &PersonMentionUpdateForm { read }, + PersonMentionUpdateForm { read }, ) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; diff --git a/crates/api/src/local_user/notifications/mark_reply_read.rs b/crates/api/src/local_user/notifications/mark_reply_read.rs index 4071a466d..ece84b5bc 100644 --- a/crates/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/src/local_user/notifications/mark_reply_read.rs @@ -37,7 +37,7 @@ impl Perform for MarkCommentReplyAsRead { CommentReply::update( &mut context.pool(), comment_reply_id, - &CommentReplyUpdateForm { read }, + CommentReplyUpdateForm { read }, ) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; diff --git a/crates/api/src/local_user/verify_email.rs b/crates/api/src/local_user/verify_email.rs index a0c4763a6..48baccf16 100644 --- a/crates/api/src/local_user/verify_email.rs +++ b/crates/api/src/local_user/verify_email.rs @@ -31,7 +31,7 @@ impl Perform for VerifyEmail { .build(); let local_user_id = verification.local_user_id; - LocalUser::update(&mut context.pool(), local_user_id, &form).await?; + LocalUser::update(&mut context.pool(), local_user_id, form).await?; EmailVerification::delete_old_tokens_for_local_user(&mut context.pool(), local_user_id).await?; diff --git a/crates/api/src/post/feature.rs b/crates/api/src/post/feature.rs index c59eba313..15243a7bb 100644 --- a/crates/api/src/post/feature.rs +++ b/crates/api/src/post/feature.rs @@ -75,7 +75,7 @@ impl Perform for FeaturePost { is_featured_community: data.feature_type == PostFeatureType::Community, }; - ModFeaturePost::create(&mut context.pool(), &form).await?; + ModFeaturePost::create(&mut context.pool(), form).await?; build_post_response( context, diff --git a/crates/api/src/post/lock.rs b/crates/api/src/post/lock.rs index 627e9d8eb..98a64a152 100644 --- a/crates/api/src/post/lock.rs +++ b/crates/api/src/post/lock.rs @@ -64,7 +64,7 @@ impl Perform for LockPost { post_id: data.post_id, locked: Some(locked), }; - ModLockPost::create(&mut context.pool(), &form).await?; + ModLockPost::create(&mut context.pool(), form).await?; build_post_response( context, diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index 3781c73f2..b93a9699a 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -54,7 +54,7 @@ impl Perform for LeaveAdmin { removed: Some(true), }; - ModAdd::create(&mut context.pool(), &form).await?; + ModAdd::create(&mut context.pool(), form).await?; // Reread site and admins let site_view = SiteView::read_local(&mut context.pool()).await?; diff --git a/crates/api/src/site/purge/comment.rs b/crates/api/src/site/purge/comment.rs index 9334961e9..2092f373c 100644 --- a/crates/api/src/site/purge/comment.rs +++ b/crates/api/src/site/purge/comment.rs @@ -45,7 +45,7 @@ impl Perform for PurgeComment { post_id, }; - AdminPurgeComment::create(&mut context.pool(), &form).await?; + AdminPurgeComment::create(&mut context.pool(), form).await?; Ok(PurgeItemResponse { success: true }) } diff --git a/crates/api/src/site/purge/community.rs b/crates/api/src/site/purge/community.rs index 56e757176..30e917801 100644 --- a/crates/api/src/site/purge/community.rs +++ b/crates/api/src/site/purge/community.rs @@ -61,7 +61,7 @@ impl Perform for PurgeCommunity { reason, }; - AdminPurgeCommunity::create(&mut context.pool(), &form).await?; + AdminPurgeCommunity::create(&mut context.pool(), form).await?; Ok(PurgeItemResponse { success: true }) } diff --git a/crates/api/src/site/purge/person.rs b/crates/api/src/site/purge/person.rs index fa884147f..4230936e6 100644 --- a/crates/api/src/site/purge/person.rs +++ b/crates/api/src/site/purge/person.rs @@ -60,7 +60,7 @@ impl Perform for PurgePerson { reason, }; - AdminPurgePerson::create(&mut context.pool(), &form).await?; + AdminPurgePerson::create(&mut context.pool(), form).await?; Ok(PurgeItemResponse { success: true }) } diff --git a/crates/api/src/site/purge/post.rs b/crates/api/src/site/purge/post.rs index 6824e408b..0196fb4ba 100644 --- a/crates/api/src/site/purge/post.rs +++ b/crates/api/src/site/purge/post.rs @@ -57,7 +57,7 @@ impl Perform for PurgePost { community_id, }; - AdminPurgePost::create(&mut context.pool(), &form).await?; + AdminPurgePost::create(&mut context.pool(), form).await?; Ok(PurgeItemResponse { success: true }) } diff --git a/crates/api_common/src/utils.rs b/crates/api_common/src/utils.rs index d259b9e4c..6b5156eb5 100644 --- a/crates/api_common/src/utils.rs +++ b/crates/api_common/src/utils.rs @@ -372,7 +372,7 @@ pub async fn send_verification_email( settings.get_protocol_and_hostname(), &form.verification_token ); - EmailVerification::create(pool, &form).await?; + EmailVerification::create(pool, form).await?; let lang = get_interface_language(user); let subject = lang.verify_email_subject(&settings.hostname); diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index 098d1a664..3a614efc4 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -166,7 +166,7 @@ impl PerformCrud for CreateComment { CommentReply::update( &mut context.pool(), reply.id, - &CommentReplyUpdateForm { read: Some(true) }, + CommentReplyUpdateForm { read: Some(true) }, ) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateReplies)?; @@ -180,7 +180,7 @@ impl PerformCrud for CreateComment { PersonMention::update( &mut context.pool(), mention.id, - &PersonMentionUpdateForm { read: Some(true) }, + PersonMentionUpdateForm { read: Some(true) }, ) .await .with_lemmy_type(LemmyErrorType::CouldntUpdatePersonMentions)?; diff --git a/crates/api_crud/src/comment/remove.rs b/crates/api_crud/src/comment/remove.rs index e87eb425b..8c30ecd78 100644 --- a/crates/api_crud/src/comment/remove.rs +++ b/crates/api_crud/src/comment/remove.rs @@ -61,7 +61,7 @@ impl PerformCrud for RemoveComment { removed: Some(removed), reason: data.reason.clone(), }; - ModRemoveComment::create(&mut context.pool(), &form).await?; + ModRemoveComment::create(&mut context.pool(), form).await?; let post_id = updated_comment.post_id; let post = Post::read(&mut context.pool(), post_id).await?; diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 0129e87c2..4b3a1e710 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -72,7 +72,7 @@ impl PerformCrud for EditComment { .language_id(data.language_id) .updated(Some(Some(naive_now()))) .build(); - let updated_comment = Comment::update(&mut context.pool(), comment_id, &form) + let updated_comment = Comment::update(&mut context.pool(), comment_id, form) .await .with_lemmy_type(LemmyErrorType::CouldntUpdateComment)?; diff --git a/crates/api_crud/src/community/remove.rs b/crates/api_crud/src/community/remove.rs index 2bcd3d857..d75dd4dcf 100644 --- a/crates/api_crud/src/community/remove.rs +++ b/crates/api_crud/src/community/remove.rs @@ -52,7 +52,7 @@ impl PerformCrud for RemoveCommunity { reason: data.reason.clone(), expires, }; - ModRemoveCommunity::create(&mut context.pool(), &form).await?; + ModRemoveCommunity::create(&mut context.pool(), form).await?; build_community_response(context, local_user_view, community_id).await } diff --git a/crates/api_crud/src/post/remove.rs b/crates/api_crud/src/post/remove.rs index 7950d5047..3bb432e10 100644 --- a/crates/api_crud/src/post/remove.rs +++ b/crates/api_crud/src/post/remove.rs @@ -59,7 +59,7 @@ impl PerformCrud for RemovePost { removed: Some(removed), reason: data.reason.clone(), }; - ModRemovePost::create(&mut context.pool(), &form).await?; + ModRemovePost::create(&mut context.pool(), form).await?; build_post_response( context, diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index caba9bd8a..a498c4aa8 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -151,7 +151,7 @@ impl PerformCrud for Register { answer: data.answer.clone().expect("must have an answer"), }; - RegistrationApplication::create(&mut context.pool(), &form).await?; + RegistrationApplication::create(&mut context.pool(), form).await?; } // Email the admins diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 55642f862..453367af8 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -181,7 +181,7 @@ impl ActivityHandler for BlockUser { banned: Some(true), expires, }; - ModBan::create(&mut context.pool(), &form).await?; + ModBan::create(&mut context.pool(), form).await?; } SiteOrCommunity::Community(community) => { let community_user_ban_form = CommunityPersonBanForm { @@ -189,7 +189,7 @@ impl ActivityHandler for BlockUser { person_id: blocked_person.id, expires: Some(expires), }; - CommunityPersonBan::ban(&mut context.pool(), &community_user_ban_form).await?; + CommunityPersonBan::ban(&mut context.pool(), community_user_ban_form).await?; // Also unsubscribe them from the community, if they are subscribed let community_follower_form = CommunityFollowerForm { @@ -215,7 +215,7 @@ impl ActivityHandler for BlockUser { banned: Some(true), expires, }; - ModBanFromCommunity::create(&mut context.pool(), &form).await?; + ModBanFromCommunity::create(&mut context.pool(), form).await?; } } diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index f68349794..74a0faa8c 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -120,7 +120,7 @@ impl ActivityHandler for UndoBlockUser { banned: Some(false), expires, }; - ModBan::create(&mut context.pool(), &form).await?; + ModBan::create(&mut context.pool(), form).await?; } SiteOrCommunity::Community(community) => { let community_user_ban_form = CommunityPersonBanForm { @@ -128,7 +128,7 @@ impl ActivityHandler for UndoBlockUser { person_id: blocked_person.id, expires: None, }; - CommunityPersonBan::unban(&mut context.pool(), &community_user_ban_form).await?; + CommunityPersonBan::unban(&mut context.pool(), community_user_ban_form).await?; // write to mod log let form = ModBanFromCommunityForm { @@ -139,7 +139,7 @@ impl ActivityHandler for UndoBlockUser { banned: Some(false), expires, }; - ModBanFromCommunity::create(&mut context.pool(), &form).await?; + ModBanFromCommunity::create(&mut context.pool(), form).await?; } } diff --git a/crates/apub/src/activities/community/collection_add.rs b/crates/apub/src/activities/community/collection_add.rs index c36a8f0da..dbcfe60d4 100644 --- a/crates/apub/src/activities/community/collection_add.rs +++ b/crates/apub/src/activities/community/collection_add.rs @@ -137,7 +137,7 @@ impl ActivityHandler for CollectionAdd { community_id: community.id, person_id: new_mod.id, }; - CommunityModerator::join(&mut context.pool(), &form).await?; + CommunityModerator::join(&mut context.pool(), form).await?; // write mod log let actor = self.actor.dereference(context).await?; @@ -147,7 +147,7 @@ impl ActivityHandler for CollectionAdd { community_id: community.id, removed: Some(false), }; - ModAddCommunity::create(&mut context.pool(), &form).await?; + ModAddCommunity::create(&mut context.pool(), form).await?; } // TODO: send websocket notification about added mod } @@ -158,7 +158,7 @@ impl ActivityHandler for CollectionAdd { let form = PostUpdateForm::builder() .featured_community(Some(true)) .build(); - Post::update(&mut context.pool(), post.id, &form).await?; + Post::update(&mut context.pool(), post.id, form).await?; } } Ok(()) diff --git a/crates/apub/src/activities/community/collection_remove.rs b/crates/apub/src/activities/community/collection_remove.rs index 28214284b..261194136 100644 --- a/crates/apub/src/activities/community/collection_remove.rs +++ b/crates/apub/src/activities/community/collection_remove.rs @@ -123,7 +123,7 @@ impl ActivityHandler for CollectionRemove { community_id: community.id, person_id: remove_mod.id, }; - CommunityModerator::leave(&mut context.pool(), &form).await?; + CommunityModerator::leave(&mut context.pool(), form).await?; // write mod log let actor = self.actor.dereference(context).await?; @@ -133,7 +133,7 @@ impl ActivityHandler for CollectionRemove { community_id: community.id, removed: Some(true), }; - ModAddCommunity::create(&mut context.pool(), &form).await?; + ModAddCommunity::create(&mut context.pool(), form).await?; // TODO: send websocket notification about removed mod } @@ -144,7 +144,7 @@ impl ActivityHandler for CollectionRemove { let form = PostUpdateForm::builder() .featured_community(Some(false)) .build(); - Post::update(&mut context.pool(), post.id, &form).await?; + Post::update(&mut context.pool(), post.id, form).await?; } } Ok(()) diff --git a/crates/apub/src/activities/community/lock_page.rs b/crates/apub/src/activities/community/lock_page.rs index 94135ede9..89e905aeb 100644 --- a/crates/apub/src/activities/community/lock_page.rs +++ b/crates/apub/src/activities/community/lock_page.rs @@ -60,7 +60,7 @@ impl ActivityHandler for LockPage { async fn receive(self, context: &Data) -> Result<(), Self::Error> { let form = PostUpdateForm::builder().locked(Some(true)).build(); let post = self.object.dereference(context).await?; - Post::update(&mut context.pool(), post.id, &form).await?; + Post::update(&mut context.pool(), post.id, form).await?; Ok(()) } } @@ -97,7 +97,7 @@ impl ActivityHandler for UndoLockPage { async fn receive(self, context: &Data) -> Result<(), Self::Error> { let form = PostUpdateForm::builder().locked(Some(false)).build(); let post = self.object.object.dereference(context).await?; - Post::update(&mut context.pool(), post.id, &form).await?; + Post::update(&mut context.pool(), post.id, form).await?; Ok(()) } } diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index fcdede8d7..d6da7f4f4 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -117,7 +117,7 @@ pub(in crate::activities) async fn receive_remove_action( reason, expires: None, }; - ModRemoveCommunity::create(&mut context.pool(), &form).await?; + ModRemoveCommunity::create(&mut context.pool(), form).await?; Community::update( &mut context.pool(), community.id, @@ -132,7 +132,7 @@ pub(in crate::activities) async fn receive_remove_action( removed: Some(true), reason, }; - ModRemovePost::create(&mut context.pool(), &form).await?; + ModRemovePost::create(&mut context.pool(), form).await?; Post::update( &mut context.pool(), post.id, @@ -147,7 +147,7 @@ pub(in crate::activities) async fn receive_remove_action( removed: Some(true), reason, }; - ModRemoveComment::create(&mut context.pool(), &form).await?; + ModRemoveComment::create(&mut context.pool(), form).await?; Comment::update( &mut context.pool(), comment.id, diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index 541a7455f..7ac952a6b 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -109,7 +109,7 @@ impl UndoDelete { reason: None, expires: None, }; - ModRemoveCommunity::create(&mut context.pool(), &form).await?; + ModRemoveCommunity::create(&mut context.pool(), form).await?; Community::update( &mut context.pool(), community.id, @@ -124,7 +124,7 @@ impl UndoDelete { removed: Some(false), reason: None, }; - ModRemovePost::create(&mut context.pool(), &form).await?; + ModRemovePost::create(&mut context.pool(), form).await?; Post::update( &mut context.pool(), post.id, @@ -139,7 +139,7 @@ impl UndoDelete { removed: Some(false), reason: None, }; - ModRemoveComment::create(&mut context.pool(), &form).await?; + ModRemoveComment::create(&mut context.pool(), form).await?; Comment::update( &mut context.pool(), comment.id, diff --git a/crates/apub/src/activities/following/follow.rs b/crates/apub/src/activities/following/follow.rs index 2f0f5037a..ba960819e 100644 --- a/crates/apub/src/activities/following/follow.rs +++ b/crates/apub/src/activities/following/follow.rs @@ -113,7 +113,7 @@ impl ActivityHandler for Follow { follower_id: actor.id, pending: false, }; - PersonFollower::follow(&mut context.pool(), &form).await?; + PersonFollower::follow(&mut context.pool(), form).await?; } UserOrCommunity::Community(c) => { let form = CommunityFollowerForm { @@ -121,7 +121,7 @@ impl ActivityHandler for Follow { person_id: actor.id, pending: false, }; - CommunityFollower::follow(&mut context.pool(), &form).await?; + CommunityFollower::follow(&mut context.pool(), form).await?; } } diff --git a/crates/apub/src/activities/following/undo_follow.rs b/crates/apub/src/activities/following/undo_follow.rs index c36b36df8..04737574b 100644 --- a/crates/apub/src/activities/following/undo_follow.rs +++ b/crates/apub/src/activities/following/undo_follow.rs @@ -82,7 +82,7 @@ impl ActivityHandler for UndoFollow { follower_id: person.id, pending: false, }; - PersonFollower::unfollow(&mut context.pool(), &form).await?; + PersonFollower::unfollow(&mut context.pool(), form).await?; } UserOrCommunity::Community(c) => { let form = CommunityFollowerForm { @@ -90,7 +90,7 @@ impl ActivityHandler for UndoFollow { person_id: person.id, pending: false, }; - CommunityFollower::unfollow(&mut context.pool(), &form).await?; + CommunityFollower::unfollow(&mut context.pool(), form).await?; } } diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 2954de096..e665cdcfc 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -76,7 +76,7 @@ impl Object for ApubComment { async fn delete(self, context: &Data) -> Result<(), LemmyError> { if !self.deleted { let form = CommentUpdateForm::builder().deleted(Some(true)).build(); - Comment::update(&mut context.pool(), self.id, &form).await?; + Comment::update(&mut context.pool(), self.id, form).await?; } Ok(()) } diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 75eb941b1..5a19ea1a6 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -75,7 +75,7 @@ impl Object for ApubCommunity { #[tracing::instrument(skip_all)] async fn delete(self, context: &Data) -> Result<(), LemmyError> { let form = CommunityUpdateForm::builder().deleted(Some(true)).build(); - Community::update(&mut context.pool(), self.id, &form).await?; + Community::update(&mut context.pool(), self.id, form).await?; Ok(()) } @@ -133,7 +133,7 @@ impl Object for ApubCommunity { let languages = LanguageTag::to_language_id_multiple(group.language, &mut context.pool()).await?; - let community = Community::create(&mut context.pool(), &form).await?; + let community = Community::create(&mut context.pool(), form).await?; CommunityLanguage::update(&mut context.pool(), languages, community.id).await?; let community: ApubCommunity = community.into(); diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index d28f8c7cf..d1678c2c1 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -78,7 +78,7 @@ impl Object for ApubPerson { #[tracing::instrument(skip_all)] async fn delete(self, context: &Data) -> Result<(), LemmyError> { let form = PersonUpdateForm::builder().deleted(Some(true)).build(); - DbPerson::update(&mut context.pool(), self.id, &form).await?; + DbPerson::update(&mut context.pool(), self.id, form).await?; Ok(()) } diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 48b573d30..de77fa04e 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -94,7 +94,7 @@ impl Object for ApubPost { async fn delete(self, context: &Data) -> Result<(), LemmyError> { if !self.deleted { let form = PostUpdateForm::builder().deleted(Some(true)).build(); - Post::update(&mut context.pool(), self.id, &form).await?; + Post::update(&mut context.pool(), self.id, form).await?; } Ok(()) } @@ -262,7 +262,7 @@ impl Object for ApubPost { .build() }; - let post = Post::create(&mut context.pool(), &form).await?; + let post = Post::create(&mut context.pool(), form).await?; // write mod log entry for lock if Page::is_locked_changed(&old_post, &page.comments_enabled) { @@ -271,7 +271,7 @@ impl Object for ApubPost { post_id: post.id, locked: Some(post.locked), }; - ModLockPost::create(&mut context.pool(), &form).await?; + ModLockPost::create(&mut context.pool(), form).await?; } Ok(post.into()) diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index 69a2638ad..7d18f2617 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -129,7 +129,7 @@ impl Object for ApubPrivateMessage { ap_id: Some(note.id.into()), local: Some(false), }; - let pm = PrivateMessage::create(&mut context.pool(), &form).await?; + let pm = PrivateMessage::create(&mut context.pool(), form).await?; Ok(pm.into()) } } diff --git a/crates/db_schema/src/impls/captcha_answer.rs b/crates/db_schema/src/impls/captcha_answer.rs index 0404ce005..3c3da529e 100644 --- a/crates/db_schema/src/impls/captcha_answer.rs +++ b/crates/db_schema/src/impls/captcha_answer.rs @@ -67,7 +67,7 @@ mod tests { let inserted = CaptchaAnswer::insert( pool, - &CaptchaAnswerForm { + CaptchaAnswerForm { answer: "XYZ".to_string(), }, ) @@ -95,7 +95,7 @@ mod tests { let inserted = CaptchaAnswer::insert( pool, - &CaptchaAnswerForm { + CaptchaAnswerForm { answer: "XYZ".to_string(), }, ) diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 88757cd02..139add14d 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -158,14 +158,14 @@ impl Crud for Comment { type IdType = CommentId; /// This is unimplemented, use [[Comment::create]] - async fn create(_pool: &mut DbPool<'_>, _comment_form: &Self::InsertForm) -> Result { + async fn create(_pool: &mut DbPool<'_>, _comment_form: Self::InsertForm) -> Result { unimplemented!(); } async fn update( pool: &mut DbPool<'_>, comment_id: CommentId, - comment_form: &Self::UpdateForm, + comment_form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(comment.find(comment_id)) @@ -179,7 +179,7 @@ impl Crud for Comment { impl Likeable for CommentLike { type Form = CommentLikeForm; type IdType = CommentId; - async fn like(pool: &mut DbPool<'_>, comment_like_form: &CommentLikeForm) -> Result { + async fn like(pool: &mut DbPool<'_>, comment_like_form: CommentLikeForm) -> Result { use crate::schema::comment_like::dsl::{comment_id, comment_like, person_id}; let conn = &mut get_conn(pool).await?; insert_into(comment_like) @@ -212,7 +212,7 @@ impl Saveable for CommentSaved { type Form = CommentSavedForm; async fn save( pool: &mut DbPool<'_>, - comment_saved_form: &CommentSavedForm, + comment_saved_form: CommentSavedForm, ) -> Result { use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id}; let conn = &mut get_conn(pool).await?; @@ -226,7 +226,7 @@ impl Saveable for CommentSaved { } async fn unsave( pool: &mut DbPool<'_>, - comment_saved_form: &CommentSavedForm, + comment_saved_form: CommentSavedForm, ) -> Result { use crate::schema::comment_saved::dsl::{comment_id, comment_saved, person_id}; let conn = &mut get_conn(pool).await?; diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index c5b5a3c6a..99acfe4c2 100644 --- a/crates/db_schema/src/impls/comment_reply.rs +++ b/crates/db_schema/src/impls/comment_reply.rs @@ -16,7 +16,7 @@ impl Crud for CommentReply { async fn create( pool: &mut DbPool<'_>, - comment_reply_form: &Self::InsertForm, + comment_reply_form: Self::InsertForm, ) -> Result { let conn = &mut get_conn(pool).await?; @@ -34,7 +34,7 @@ impl Crud for CommentReply { async fn update( pool: &mut DbPool<'_>, comment_reply_id: CommentReplyId, - comment_reply_form: &Self::UpdateForm, + comment_reply_form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(comment_reply.find(comment_reply_id)) diff --git a/crates/db_schema/src/impls/comment_report.rs b/crates/db_schema/src/impls/comment_report.rs index ff93915e1..fe5cf4de3 100644 --- a/crates/db_schema/src/impls/comment_report.rs +++ b/crates/db_schema/src/impls/comment_report.rs @@ -23,7 +23,7 @@ impl Reportable for CommentReport { /// * `comment_report_form` - the filled CommentReportForm to insert async fn report( pool: &mut DbPool<'_>, - comment_report_form: &CommentReportForm, + comment_report_form: CommentReportForm, ) -> Result { let conn = &mut get_conn(pool).await?; insert_into(comment_report) diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 2d0fcfe57..67e8035f7 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -28,7 +28,7 @@ impl Crud for Community { type UpdateForm = CommunityUpdateForm; type IdType = CommunityId; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { let is_new_community = match &form.actor_id { Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(), None => true, @@ -55,7 +55,7 @@ impl Crud for Community { async fn update( pool: &mut DbPool<'_>, community_id: CommunityId, - form: &Self::UpdateForm, + form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(community::table.find(community_id)) @@ -70,7 +70,7 @@ impl Joinable for CommunityModerator { type Form = CommunityModeratorForm; async fn join( pool: &mut DbPool<'_>, - community_moderator_form: &CommunityModeratorForm, + community_moderator_form: CommunityModeratorForm, ) -> Result { use crate::schema::community_moderator::dsl::community_moderator; let conn = &mut get_conn(pool).await?; @@ -82,7 +82,7 @@ impl Joinable for CommunityModerator { async fn leave( pool: &mut DbPool<'_>, - community_moderator_form: &CommunityModeratorForm, + community_moderator_form: CommunityModeratorForm, ) -> Result { use crate::schema::community_moderator::dsl::{community_id, community_moderator, person_id}; let conn = &mut get_conn(pool).await?; @@ -171,7 +171,7 @@ impl Bannable for CommunityPersonBan { type Form = CommunityPersonBanForm; async fn ban( pool: &mut DbPool<'_>, - community_person_ban_form: &CommunityPersonBanForm, + community_person_ban_form: CommunityPersonBanForm, ) -> Result { use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id}; let conn = &mut get_conn(pool).await?; @@ -186,7 +186,7 @@ impl Bannable for CommunityPersonBan { async fn unban( pool: &mut DbPool<'_>, - community_person_ban_form: &CommunityPersonBanForm, + community_person_ban_form: CommunityPersonBanForm, ) -> Result { use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id}; let conn = &mut get_conn(pool).await?; @@ -219,7 +219,7 @@ impl CommunityFollower { #[async_trait] impl Followable for CommunityFollower { type Form = CommunityFollowerForm; - async fn follow(pool: &mut DbPool<'_>, form: &CommunityFollowerForm) -> Result { + async fn follow(pool: &mut DbPool<'_>, form: CommunityFollowerForm) -> Result { use crate::schema::community_follower::dsl::{community_follower, community_id, person_id}; let conn = &mut get_conn(pool).await?; insert_into(community_follower) @@ -251,7 +251,7 @@ impl Followable for CommunityFollower { .get_result::(conn) .await } - async fn unfollow(pool: &mut DbPool<'_>, form: &CommunityFollowerForm) -> Result { + async fn unfollow(pool: &mut DbPool<'_>, form: CommunityFollowerForm) -> Result { use crate::schema::community_follower::dsl::{community_follower, community_id, person_id}; let conn = &mut get_conn(pool).await?; diesel::delete( @@ -435,7 +435,7 @@ mod tests { expires: None, }; - let inserted_community_person_ban = CommunityPersonBan::ban(pool, &community_person_ban_form) + let inserted_community_person_ban = CommunityPersonBan::ban(pool, community_person_ban_form) .await .unwrap(); @@ -462,7 +462,7 @@ mod tests { let left_community = CommunityModerator::leave(pool, &community_moderator_form) .await .unwrap(); - let unban = CommunityPersonBan::unban(pool, &community_person_ban_form) + let unban = CommunityPersonBan::unban(pool, community_person_ban_form) .await .unwrap(); let num_deleted = Community::delete(pool, inserted_community.id) diff --git a/crates/db_schema/src/impls/community_block.rs b/crates/db_schema/src/impls/community_block.rs index 9dc21bf2f..d63bdd25b 100644 --- a/crates/db_schema/src/impls/community_block.rs +++ b/crates/db_schema/src/impls/community_block.rs @@ -10,7 +10,7 @@ use diesel_async::RunQueryDsl; #[async_trait] impl Blockable for CommunityBlock { type Form = CommunityBlockForm; - async fn block(pool: &mut DbPool<'_>, community_block_form: &Self::Form) -> Result { + async fn block(pool: &mut DbPool<'_>, community_block_form: Self::Form) -> Result { let conn = &mut get_conn(pool).await?; insert_into(community_block) .values(community_block_form) @@ -22,7 +22,7 @@ impl Blockable for CommunityBlock { } async fn unblock( pool: &mut DbPool<'_>, - community_block_form: &Self::Form, + community_block_form: Self::Form, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::delete( diff --git a/crates/db_schema/src/impls/local_user.rs b/crates/db_schema/src/impls/local_user.rs index 6ef3421d3..7eb189147 100644 --- a/crates/db_schema/src/impls/local_user.rs +++ b/crates/db_schema/src/impls/local_user.rs @@ -70,7 +70,7 @@ impl Crud for LocalUser { type UpdateForm = LocalUserUpdateForm; type IdType = LocalUserId; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { let conn = &mut get_conn(pool).await?; let mut form_with_encrypted_password = form.clone(); let password_hash = @@ -97,7 +97,7 @@ impl Crud for LocalUser { async fn update( pool: &mut DbPool<'_>, local_user_id: LocalUserId, - form: &Self::UpdateForm, + form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(local_user.find(local_user_id)) diff --git a/crates/db_schema/src/impls/moderator.rs b/crates/db_schema/src/impls/moderator.rs index a4c300b2a..5457f8cd5 100644 --- a/crates/db_schema/src/impls/moderator.rs +++ b/crates/db_schema/src/impls/moderator.rs @@ -43,7 +43,7 @@ impl Crud for ModRemovePost { type UpdateForm = ModRemovePostForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModRemovePostForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModRemovePostForm) -> Result { use crate::schema::mod_remove_post::dsl::mod_remove_post; let conn = &mut get_conn(pool).await?; insert_into(mod_remove_post) @@ -55,7 +55,7 @@ impl Crud for ModRemovePost { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModRemovePostForm, + form: ModRemovePostForm, ) -> Result { use crate::schema::mod_remove_post::dsl::mod_remove_post; let conn = &mut get_conn(pool).await?; @@ -72,7 +72,7 @@ impl Crud for ModLockPost { type UpdateForm = ModLockPostForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModLockPostForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModLockPostForm) -> Result { use crate::schema::mod_lock_post::dsl::mod_lock_post; let conn = &mut get_conn(pool).await?; insert_into(mod_lock_post) @@ -84,7 +84,7 @@ impl Crud for ModLockPost { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModLockPostForm, + form: ModLockPostForm, ) -> Result { use crate::schema::mod_lock_post::dsl::mod_lock_post; let conn = &mut get_conn(pool).await?; @@ -101,7 +101,7 @@ impl Crud for ModFeaturePost { type UpdateForm = ModFeaturePostForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModFeaturePostForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModFeaturePostForm) -> Result { use crate::schema::mod_feature_post::dsl::mod_feature_post; let conn = &mut get_conn(pool).await?; insert_into(mod_feature_post) @@ -113,7 +113,7 @@ impl Crud for ModFeaturePost { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModFeaturePostForm, + form: ModFeaturePostForm, ) -> Result { use crate::schema::mod_feature_post::dsl::mod_feature_post; let conn = &mut get_conn(pool).await?; @@ -130,7 +130,7 @@ impl Crud for ModRemoveComment { type UpdateForm = ModRemoveCommentForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommentForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModRemoveCommentForm) -> Result { use crate::schema::mod_remove_comment::dsl::mod_remove_comment; let conn = &mut get_conn(pool).await?; insert_into(mod_remove_comment) @@ -142,7 +142,7 @@ impl Crud for ModRemoveComment { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModRemoveCommentForm, + form: ModRemoveCommentForm, ) -> Result { use crate::schema::mod_remove_comment::dsl::mod_remove_comment; let conn = &mut get_conn(pool).await?; @@ -159,7 +159,7 @@ impl Crud for ModRemoveCommunity { type UpdateForm = ModRemoveCommunityForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModRemoveCommunityForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModRemoveCommunityForm) -> Result { use crate::schema::mod_remove_community::dsl::mod_remove_community; let conn = &mut get_conn(pool).await?; insert_into(mod_remove_community) @@ -171,7 +171,7 @@ impl Crud for ModRemoveCommunity { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModRemoveCommunityForm, + form: ModRemoveCommunityForm, ) -> Result { use crate::schema::mod_remove_community::dsl::mod_remove_community; let conn = &mut get_conn(pool).await?; @@ -188,7 +188,7 @@ impl Crud for ModBanFromCommunity { type UpdateForm = ModBanFromCommunityForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModBanFromCommunityForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModBanFromCommunityForm) -> Result { use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community; let conn = &mut get_conn(pool).await?; insert_into(mod_ban_from_community) @@ -200,7 +200,7 @@ impl Crud for ModBanFromCommunity { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModBanFromCommunityForm, + form: ModBanFromCommunityForm, ) -> Result { use crate::schema::mod_ban_from_community::dsl::mod_ban_from_community; let conn = &mut get_conn(pool).await?; @@ -217,7 +217,7 @@ impl Crud for ModBan { type UpdateForm = ModBanForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModBanForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModBanForm) -> Result { use crate::schema::mod_ban::dsl::mod_ban; let conn = &mut get_conn(pool).await?; insert_into(mod_ban) @@ -226,7 +226,7 @@ impl Crud for ModBan { .await } - async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModBanForm) -> Result { + async fn update(pool: &mut DbPool<'_>, from_id: i32, form: ModBanForm) -> Result { use crate::schema::mod_ban::dsl::mod_ban; let conn = &mut get_conn(pool).await?; diesel::update(mod_ban.find(from_id)) @@ -242,7 +242,7 @@ impl Crud for ModHideCommunity { type UpdateForm = ModHideCommunityForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModHideCommunityForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModHideCommunityForm) -> Result { use crate::schema::mod_hide_community::dsl::mod_hide_community; let conn = &mut get_conn(pool).await?; insert_into(mod_hide_community) @@ -254,7 +254,7 @@ impl Crud for ModHideCommunity { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModHideCommunityForm, + form: ModHideCommunityForm, ) -> Result { use crate::schema::mod_hide_community::dsl::mod_hide_community; let conn = &mut get_conn(pool).await?; @@ -271,7 +271,7 @@ impl Crud for ModAddCommunity { type UpdateForm = ModAddCommunityForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModAddCommunityForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModAddCommunityForm) -> Result { use crate::schema::mod_add_community::dsl::mod_add_community; let conn = &mut get_conn(pool).await?; insert_into(mod_add_community) @@ -283,7 +283,7 @@ impl Crud for ModAddCommunity { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModAddCommunityForm, + form: ModAddCommunityForm, ) -> Result { use crate::schema::mod_add_community::dsl::mod_add_community; let conn = &mut get_conn(pool).await?; @@ -300,7 +300,7 @@ impl Crud for ModTransferCommunity { type UpdateForm = ModTransferCommunityForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModTransferCommunityForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModTransferCommunityForm) -> Result { use crate::schema::mod_transfer_community::dsl::mod_transfer_community; let conn = &mut get_conn(pool).await?; insert_into(mod_transfer_community) @@ -312,7 +312,7 @@ impl Crud for ModTransferCommunity { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &ModTransferCommunityForm, + form: ModTransferCommunityForm, ) -> Result { use crate::schema::mod_transfer_community::dsl::mod_transfer_community; let conn = &mut get_conn(pool).await?; @@ -329,7 +329,7 @@ impl Crud for ModAdd { type UpdateForm = ModAddForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &ModAddForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: ModAddForm) -> Result { use crate::schema::mod_add::dsl::mod_add; let conn = &mut get_conn(pool).await?; insert_into(mod_add) @@ -338,7 +338,7 @@ impl Crud for ModAdd { .await } - async fn update(pool: &mut DbPool<'_>, from_id: i32, form: &ModAddForm) -> Result { + async fn update(pool: &mut DbPool<'_>, from_id: i32, form: ModAddForm) -> Result { use crate::schema::mod_add::dsl::mod_add; let conn = &mut get_conn(pool).await?; diesel::update(mod_add.find(from_id)) @@ -354,7 +354,7 @@ impl Crud for AdminPurgePerson { type UpdateForm = AdminPurgePersonForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { use crate::schema::admin_purge_person::dsl::admin_purge_person; let conn = &mut get_conn(pool).await?; insert_into(admin_purge_person) @@ -366,7 +366,7 @@ impl Crud for AdminPurgePerson { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &Self::InsertForm, + form: Self::InsertForm, ) -> Result { use crate::schema::admin_purge_person::dsl::admin_purge_person; let conn = &mut get_conn(pool).await?; @@ -383,7 +383,7 @@ impl Crud for AdminPurgeCommunity { type UpdateForm = AdminPurgeCommunityForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { use crate::schema::admin_purge_community::dsl::admin_purge_community; let conn = &mut get_conn(pool).await?; insert_into(admin_purge_community) @@ -395,7 +395,7 @@ impl Crud for AdminPurgeCommunity { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &Self::InsertForm, + form: Self::InsertForm, ) -> Result { use crate::schema::admin_purge_community::dsl::admin_purge_community; let conn = &mut get_conn(pool).await?; @@ -412,7 +412,7 @@ impl Crud for AdminPurgePost { type UpdateForm = AdminPurgePostForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { use crate::schema::admin_purge_post::dsl::admin_purge_post; let conn = &mut get_conn(pool).await?; insert_into(admin_purge_post) @@ -424,7 +424,7 @@ impl Crud for AdminPurgePost { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &Self::InsertForm, + form: Self::InsertForm, ) -> Result { use crate::schema::admin_purge_post::dsl::admin_purge_post; let conn = &mut get_conn(pool).await?; @@ -441,7 +441,7 @@ impl Crud for AdminPurgeComment { type UpdateForm = AdminPurgeCommentForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { use crate::schema::admin_purge_comment::dsl::admin_purge_comment; let conn = &mut get_conn(pool).await?; insert_into(admin_purge_comment) @@ -453,7 +453,7 @@ impl Crud for AdminPurgeComment { async fn update( pool: &mut DbPool<'_>, from_id: i32, - form: &Self::InsertForm, + form: Self::InsertForm, ) -> Result { use crate::schema::admin_purge_comment::dsl::admin_purge_comment; let conn = &mut get_conn(pool).await?; diff --git a/crates/db_schema/src/impls/password_reset_request.rs b/crates/db_schema/src/impls/password_reset_request.rs index 9daaa1664..678927739 100644 --- a/crates/db_schema/src/impls/password_reset_request.rs +++ b/crates/db_schema/src/impls/password_reset_request.rs @@ -25,7 +25,7 @@ impl Crud for PasswordResetRequest { type UpdateForm = PasswordResetRequestForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &PasswordResetRequestForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: PasswordResetRequestForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(password_reset_request) .values(form) @@ -35,7 +35,7 @@ impl Crud for PasswordResetRequest { async fn update( pool: &mut DbPool<'_>, password_reset_request_id: i32, - form: &PasswordResetRequestForm, + form: PasswordResetRequestForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(password_reset_request.find(password_reset_request_id)) @@ -60,7 +60,7 @@ impl PasswordResetRequest { token_encrypted: token_hash, }; - Self::create(pool, &form).await + Self::create(pool, form).await } pub async fn read_from_token( pool: &mut DbPool<'_>, diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 53f4a4df0..2fb8f74a2 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -28,7 +28,7 @@ impl Crud for Person { .await } - async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: PersonInsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(person::table) .values(form) @@ -38,7 +38,7 @@ impl Crud for Person { async fn update( pool: &mut DbPool<'_>, person_id: PersonId, - form: &PersonUpdateForm, + form: PersonUpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(person::table.find(person_id)) @@ -151,7 +151,7 @@ impl ApubActor for Person { #[async_trait] impl Followable for PersonFollower { type Form = PersonFollowerForm; - async fn follow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result { + async fn follow(pool: &mut DbPool<'_>, form: PersonFollowerForm) -> Result { use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id}; let conn = &mut get_conn(pool).await?; insert_into(person_follower) @@ -165,7 +165,7 @@ impl Followable for PersonFollower { async fn follow_accepted(_: &mut DbPool<'_>, _: CommunityId, _: PersonId) -> Result { unimplemented!() } - async fn unfollow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result { + async fn unfollow(pool: &mut DbPool<'_>, form: PersonFollowerForm) -> Result { use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id}; let conn = &mut get_conn(pool).await?; diesel::delete( diff --git a/crates/db_schema/src/impls/person_block.rs b/crates/db_schema/src/impls/person_block.rs index 0d125cd51..4c5fff13d 100644 --- a/crates/db_schema/src/impls/person_block.rs +++ b/crates/db_schema/src/impls/person_block.rs @@ -26,10 +26,7 @@ impl PersonBlock { #[async_trait] impl Blockable for PersonBlock { type Form = PersonBlockForm; - async fn block( - pool: &mut DbPool<'_>, - person_block_form: &PersonBlockForm, - ) -> Result { + async fn block(pool: &mut DbPool<'_>, person_block_form: PersonBlockForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(person_block) .values(person_block_form) @@ -39,7 +36,7 @@ impl Blockable for PersonBlock { .get_result::(conn) .await } - async fn unblock(pool: &mut DbPool<'_>, person_block_form: &Self::Form) -> Result { + async fn unblock(pool: &mut DbPool<'_>, person_block_form: Self::Form) -> Result { let conn = &mut get_conn(pool).await?; diesel::delete( person_block diff --git a/crates/db_schema/src/impls/person_mention.rs b/crates/db_schema/src/impls/person_mention.rs index f2441f00c..f9d5b1c67 100644 --- a/crates/db_schema/src/impls/person_mention.rs +++ b/crates/db_schema/src/impls/person_mention.rs @@ -16,7 +16,7 @@ impl Crud for PersonMention { async fn create( pool: &mut DbPool<'_>, - person_mention_form: &Self::InsertForm, + person_mention_form: Self::InsertForm, ) -> Result { let conn = &mut get_conn(pool).await?; // since the return here isnt utilized, we dont need to do an update @@ -33,7 +33,7 @@ impl Crud for PersonMention { async fn update( pool: &mut DbPool<'_>, person_mention_id: PersonMentionId, - person_mention_form: &Self::UpdateForm, + person_mention_form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(person_mention.find(person_mention_id)) diff --git a/crates/db_schema/src/impls/post.rs b/crates/db_schema/src/impls/post.rs index 60b8af2ce..0335498eb 100644 --- a/crates/db_schema/src/impls/post.rs +++ b/crates/db_schema/src/impls/post.rs @@ -39,7 +39,7 @@ impl Crud for Post { type UpdateForm = PostUpdateForm; type IdType = PostId; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(post) .values(form) @@ -53,7 +53,7 @@ impl Crud for Post { async fn update( pool: &mut DbPool<'_>, post_id: PostId, - new_post: &Self::UpdateForm, + new_post: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(post.find(post_id)) @@ -229,7 +229,7 @@ impl Post { impl Likeable for PostLike { type Form = PostLikeForm; type IdType = PostId; - async fn like(pool: &mut DbPool<'_>, post_like_form: &PostLikeForm) -> Result { + async fn like(pool: &mut DbPool<'_>, post_like_form: PostLikeForm) -> Result { use crate::schema::post_like::dsl::{person_id, post_id, post_like}; let conn = &mut get_conn(pool).await?; insert_into(post_like) @@ -260,7 +260,7 @@ impl Likeable for PostLike { #[async_trait] impl Saveable for PostSaved { type Form = PostSavedForm; - async fn save(pool: &mut DbPool<'_>, post_saved_form: &PostSavedForm) -> Result { + async fn save(pool: &mut DbPool<'_>, post_saved_form: PostSavedForm) -> Result { use crate::schema::post_saved::dsl::{person_id, post_id, post_saved}; let conn = &mut get_conn(pool).await?; insert_into(post_saved) @@ -271,7 +271,7 @@ impl Saveable for PostSaved { .get_result::(conn) .await } - async fn unsave(pool: &mut DbPool<'_>, post_saved_form: &PostSavedForm) -> Result { + async fn unsave(pool: &mut DbPool<'_>, post_saved_form: PostSavedForm) -> Result { use crate::schema::post_saved::dsl::{person_id, post_id, post_saved}; let conn = &mut get_conn(pool).await?; diesel::delete( @@ -289,7 +289,7 @@ impl Readable for PostRead { type Form = PostReadForm; async fn mark_as_read( pool: &mut DbPool<'_>, - post_read_form: &PostReadForm, + post_read_form: PostReadForm, ) -> Result { use crate::schema::post_read::dsl::{person_id, post_id, post_read}; let conn = &mut get_conn(pool).await?; @@ -304,7 +304,7 @@ impl Readable for PostRead { async fn mark_as_unread( pool: &mut DbPool<'_>, - post_read_form: &PostReadForm, + post_read_form: PostReadForm, ) -> Result { use crate::schema::post_read::dsl::{person_id, post_id, post_read}; let conn = &mut get_conn(pool).await?; diff --git a/crates/db_schema/src/impls/post_report.rs b/crates/db_schema/src/impls/post_report.rs index b839d62d5..0e06ea395 100644 --- a/crates/db_schema/src/impls/post_report.rs +++ b/crates/db_schema/src/impls/post_report.rs @@ -18,7 +18,7 @@ impl Reportable for PostReport { type Form = PostReportForm; type IdType = PostReportId; - async fn report(pool: &mut DbPool<'_>, post_report_form: &PostReportForm) -> Result { + async fn report(pool: &mut DbPool<'_>, post_report_form: PostReportForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(post_report) .values(post_report_form) diff --git a/crates/db_schema/src/impls/private_message.rs b/crates/db_schema/src/impls/private_message.rs index d422f0d23..df259f275 100644 --- a/crates/db_schema/src/impls/private_message.rs +++ b/crates/db_schema/src/impls/private_message.rs @@ -16,7 +16,7 @@ impl Crud for PrivateMessage { type UpdateForm = PrivateMessageUpdateForm; type IdType = PrivateMessageId; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(private_message) .values(form) @@ -30,7 +30,7 @@ impl Crud for PrivateMessage { async fn update( pool: &mut DbPool<'_>, private_message_id: PrivateMessageId, - form: &Self::UpdateForm, + form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(private_message.find(private_message_id)) diff --git a/crates/db_schema/src/impls/private_message_report.rs b/crates/db_schema/src/impls/private_message_report.rs index ca2187960..21b771ee4 100644 --- a/crates/db_schema/src/impls/private_message_report.rs +++ b/crates/db_schema/src/impls/private_message_report.rs @@ -20,7 +20,7 @@ impl Reportable for PrivateMessageReport { async fn report( pool: &mut DbPool<'_>, - pm_report_form: &PrivateMessageReportForm, + pm_report_form: PrivateMessageReportForm, ) -> Result { let conn = &mut get_conn(pool).await?; insert_into(private_message_report) diff --git a/crates/db_schema/src/impls/registration_application.rs b/crates/db_schema/src/impls/registration_application.rs index c4df7ba69..9b25c593c 100644 --- a/crates/db_schema/src/impls/registration_application.rs +++ b/crates/db_schema/src/impls/registration_application.rs @@ -18,7 +18,7 @@ impl Crud for RegistrationApplication { type UpdateForm = RegistrationApplicationUpdateForm; type IdType = i32; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(registration_application) .values(form) @@ -29,7 +29,7 @@ impl Crud for RegistrationApplication { async fn update( pool: &mut DbPool<'_>, id_: Self::IdType, - form: &Self::UpdateForm, + form: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(registration_application.find(id_)) diff --git a/crates/db_schema/src/impls/site.rs b/crates/db_schema/src/impls/site.rs index 090989b27..c6bfe673c 100644 --- a/crates/db_schema/src/impls/site.rs +++ b/crates/db_schema/src/impls/site.rs @@ -18,7 +18,7 @@ impl Crud for Site { type UpdateForm = SiteUpdateForm; type IdType = SiteId; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result { let is_new_site = match &form.actor_id { Some(id_) => Site::read_from_apub_id(pool, id_).await?.is_none(), None => true, @@ -45,7 +45,7 @@ impl Crud for Site { async fn update( pool: &mut DbPool<'_>, site_id: SiteId, - new_site: &Self::UpdateForm, + new_site: Self::UpdateForm, ) -> Result { let conn = &mut get_conn(pool).await?; diesel::update(site.find(site_id)) diff --git a/crates/db_schema/src/traits.rs b/crates/db_schema/src/traits.rs index 7cafaef7f..b7c6af56f 100644 --- a/crates/db_schema/src/traits.rs +++ b/crates/db_schema/src/traits.rs @@ -57,7 +57,7 @@ where + Sized + Send + AsExpression<<::PrimaryKey as Expression>::SqlType>; - async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result; + async fn create(pool: &mut DbPool<'_>, form: Self::InsertForm) -> Result; /*{ let query = insert_into(Self::table()).values(form); let conn = &mut *get_conn(pool).await?; @@ -72,7 +72,7 @@ where async fn update( pool: &mut DbPool<'_>, id: Self::IdType, - form: &Self::UpdateForm, + form: Self::UpdateForm, ) -> Result; /*{ let conn = &mut get_conn(pool).await?; @@ -97,7 +97,7 @@ where //type FollowerColumn: Column + Default + Send; //type TargetColumn: Column + Default + Send; type Form; - async fn follow(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn follow(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; /*{ @@ -120,7 +120,7 @@ where ) -> Result where Self: Sized; - async fn unfollow(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn unfollow(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; } @@ -128,10 +128,10 @@ where #[async_trait] pub trait Joinable { type Form; - async fn join(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn join(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; - async fn leave(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn leave(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; } @@ -140,7 +140,7 @@ pub trait Joinable { pub trait Likeable { type Form; type IdType; - async fn like(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn like(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; async fn remove( @@ -155,10 +155,10 @@ pub trait Likeable { #[async_trait] pub trait Bannable { type Form; - async fn ban(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn ban(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; - async fn unban(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn unban(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; } @@ -166,10 +166,10 @@ pub trait Bannable { #[async_trait] pub trait Saveable { type Form; - async fn save(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn save(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; - async fn unsave(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn unsave(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; } @@ -177,10 +177,10 @@ pub trait Saveable { #[async_trait] pub trait Blockable { type Form; - async fn block(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn block(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; - async fn unblock(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn unblock(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; } @@ -188,10 +188,10 @@ pub trait Blockable { #[async_trait] pub trait Readable { type Form; - async fn mark_as_read(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn mark_as_read(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; - async fn mark_as_unread(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn mark_as_unread(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; } @@ -200,7 +200,7 @@ pub trait Readable { pub trait Reportable { type Form; type IdType; - async fn report(pool: &mut DbPool<'_>, form: &Self::Form) -> Result + async fn report(pool: &mut DbPool<'_>, form: Self::Form) -> Result where Self: Sized; async fn resolve( diff --git a/src/code_migrations.rs b/src/code_migrations.rs index ae7df3979..78ea0e29c 100644 --- a/src/code_migrations.rs +++ b/src/code_migrations.rs @@ -88,7 +88,7 @@ async fn user_updates_2020_04_02( .last_refreshed_at(Some(naive_now())) .build(); - Person::update(pool, cperson.id, &form).await?; + Person::update(pool, cperson.id, form).await?; } info!("{} person rows updated.", incorrect_persons.len()); @@ -127,7 +127,7 @@ async fn community_updates_2020_04_02( .last_refreshed_at(Some(naive_now())) .build(); - Community::update(pool, ccommunity.id, &form).await?; + Community::update(pool, ccommunity.id, form).await?; } info!("{} community rows updated.", incorrect_communities.len()); @@ -383,7 +383,7 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(), .public_key(Some(key_pair.public_key)) .private_key(Some(Some(key_pair.private_key))) .build(); - Community::update(&mut conn.into(), community_.id, &form).await?; + Community::update(&mut conn.into(), community_.id, form).await?; } } @@ -405,7 +405,7 @@ async fn regenerate_public_keys_2022_07_05(pool: &mut DbPool<'_>) -> Result<(), .public_key(Some(key_pair.public_key)) .private_key(Some(Some(key_pair.private_key))) .build(); - Person::update(pool, person_.id, &form).await?; + Person::update(pool, person_.id, form).await?; } } Ok(())