From 0d9db43b0abe218cf71468d989a048bcb182a5e7 Mon Sep 17 00:00:00 2001 From: dull b Date: Sat, 1 Jul 2023 03:26:24 +0000 Subject: [PATCH] Remove more `&mut *` --- crates/api/src/comment/distinguish.rs | 4 +-- crates/api/src/comment/like.rs | 2 +- crates/api/src/comment_report/create.rs | 9 ++--- crates/api/src/community/add_mod.rs | 2 +- crates/api/src/community/ban.rs | 5 ++- crates/api/src/community/block.rs | 9 ++--- crates/api/src/community/follow.rs | 13 +++---- crates/api/src/community/transfer.rs | 12 +++---- crates/api/src/local_user/add_admin.rs | 2 +- crates/api/src/local_user/ban_person.rs | 4 +-- crates/api/src/local_user/login.rs | 2 +- .../notifications/mark_mention_read.rs | 10 ++---- .../notifications/mark_reply_read.rs | 10 ++---- crates/api/src/local_user/report_count.rs | 10 ++---- crates/api/src/local_user/reset_password.rs | 9 ++--- crates/api/src/local_user/save_settings.rs | 9 ++--- crates/api/src/post/feature.rs | 6 ++-- crates/api/src/post/like.rs | 6 ++-- crates/api/src/post/lock.rs | 8 ++--- crates/api/src/post/mark_read.rs | 4 +-- crates/api/src/post/save.rs | 2 +- crates/api/src/post_report/create.rs | 9 ++--- crates/api/src/private_message/mark_read.rs | 2 +- .../api/src/private_message_report/create.rs | 2 +- crates/api/src/site/leave_admin.rs | 2 +- crates/api/src/site/mod_log.rs | 10 ++---- crates/api/src/site/purge/community.rs | 2 +- crates/api/src/site/purge/person.rs | 2 +- .../site/registration_applications/approve.rs | 7 +--- .../registration_applications/unread_count.rs | 8 ++--- crates/api_common/src/build_response.rs | 20 +++++------ crates/api_crud/src/comment/create.rs | 34 ++++++++----------- crates/api_crud/src/comment/delete.rs | 4 +-- crates/api_crud/src/comment/remove.rs | 6 ++-- crates/api_crud/src/comment/update.rs | 4 +-- crates/api_crud/src/community/delete.rs | 2 +- crates/api_crud/src/community/remove.rs | 2 +- crates/api_crud/src/post/create.rs | 14 ++++---- crates/api_crud/src/post/delete.rs | 6 ++-- crates/api_crud/src/post/read.rs | 8 ++--- crates/api_crud/src/post/remove.rs | 6 ++-- crates/api_crud/src/post/update.rs | 4 +-- crates/api_crud/src/private_message/create.rs | 4 +-- crates/api_crud/src/private_message/delete.rs | 2 +- crates/api_crud/src/private_message/update.rs | 2 +- crates/api_crud/src/site/update.rs | 7 +--- crates/api_crud/src/user/create.rs | 12 +++---- .../apub/src/activities/block/block_user.rs | 14 +++----- .../src/activities/block/undo_block_user.rs | 4 +-- .../activities/community/collection_add.rs | 8 ++--- .../apub/src/activities/community/update.rs | 7 +--- crates/apub/src/activities/deletion/delete.rs | 6 ++-- .../src/activities/deletion/delete_user.rs | 4 +-- crates/apub/src/activities/deletion/mod.rs | 21 ++++-------- .../src/activities/deletion/undo_delete.rs | 6 ++-- crates/apub/src/api/list_posts.rs | 2 +- crates/apub/src/api/read_community.rs | 4 +-- crates/apub/src/api/resolve_object.rs | 2 +- .../src/collections/community_moderators.rs | 19 ++++------- crates/apub/src/objects/comment.rs | 12 +++---- crates/apub/src/objects/community.rs | 2 +- crates/apub/src/objects/post.rs | 4 +-- crates/apub/src/objects/private_message.rs | 2 +- crates/db_schema/src/utils.rs | 1 - crates/routes/src/feeds.rs | 8 ++--- 65 files changed, 171 insertions(+), 274 deletions(-) diff --git a/crates/api/src/comment/distinguish.rs b/crates/api/src/comment/distinguish.rs index 2514d79c3..a686bef78 100644 --- a/crates/api/src/comment/distinguish.rs +++ b/crates/api/src/comment/distinguish.rs @@ -27,13 +27,13 @@ impl Perform for DistinguishComment { check_community_ban( local_user_view.person.id, orig_comment.community.id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; // Verify that only a mod or admin can distinguish a comment is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, orig_comment.community.id, ) diff --git a/crates/api/src/comment/like.rs b/crates/api/src/comment/like.rs index 74ba45f7b..69e0d4b78 100644 --- a/crates/api/src/comment/like.rs +++ b/crates/api/src/comment/like.rs @@ -39,7 +39,7 @@ impl Perform for CreateCommentLike { check_community_ban( local_user_view.person.id, orig_comment.community.id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; diff --git a/crates/api/src/comment_report/create.rs b/crates/api/src/comment_report/create.rs index 9df5e70dc..f5728ac93 100644 --- a/crates/api/src/comment_report/create.rs +++ b/crates/api/src/comment_report/create.rs @@ -36,12 +36,7 @@ impl Perform for CreateCommentReport { let comment_id = data.comment_id; let comment_view = CommentView::read(context.conn().await?, comment_id, None).await?; - check_community_ban( - person_id, - comment_view.community.id, - &mut *context.conn().await?, - ) - .await?; + check_community_ban(person_id, comment_view.community.id, context.conn().await?).await?; let report_form = CommentReportForm { creator_id: person_id, @@ -62,7 +57,7 @@ impl Perform for CreateCommentReport { send_new_report_email_to_admins( &comment_report_view.creator.name, &comment_report_view.comment_creator.name, - &mut *context.conn().await?, + context.conn().await?, context.settings(), ) .await?; diff --git a/crates/api/src/community/add_mod.rs b/crates/api/src/community/add_mod.rs index 40211719b..b4a95dde6 100644 --- a/crates/api/src/community/add_mod.rs +++ b/crates/api/src/community/add_mod.rs @@ -31,7 +31,7 @@ impl Perform for AddModToCommunity { // Verify that only mods or admins can add mod is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, community_id, ) diff --git a/crates/api/src/community/ban.rs b/crates/api/src/community/ban.rs index 73e773289..22e89c2f9 100644 --- a/crates/api/src/community/ban.rs +++ b/crates/api/src/community/ban.rs @@ -42,7 +42,7 @@ impl Perform for BanFromCommunity { // Verify that only mods or admins can ban is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, community_id, ) @@ -78,8 +78,7 @@ impl Perform for BanFromCommunity { // Remove/Restore their data if that's desired if remove_data { - remove_user_data_in_community(community_id, banned_person_id, &mut *context.conn().await?) - .await?; + remove_user_data_in_community(community_id, banned_person_id, context.conn().await?).await?; } // Mod tables diff --git a/crates/api/src/community/block.rs b/crates/api/src/community/block.rs index 13df3dc59..e9e09d90a 100644 --- a/crates/api/src/community/block.rs +++ b/crates/api/src/community/block.rs @@ -55,13 +55,8 @@ impl Perform for BlockCommunity { .map_err(|e| LemmyError::from_error_message(e, "community_block_already_exists"))?; } - let community_view = CommunityView::read( - &mut *context.conn().await?, - community_id, - Some(person_id), - None, - ) - .await?; + let community_view = + CommunityView::read(context.conn().await?, community_id, Some(person_id), None).await?; Ok(BlockCommunityResponse { blocked: data.block, diff --git a/crates/api/src/community/follow.rs b/crates/api/src/community/follow.rs index abf70264d..3a3167797 100644 --- a/crates/api/src/community/follow.rs +++ b/crates/api/src/community/follow.rs @@ -36,10 +36,10 @@ impl Perform for FollowCommunity { check_community_ban( local_user_view.person.id, community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(community_id, context.conn().await?).await?; CommunityFollower::follow(context.conn().await?, &community_follower_form) .await @@ -53,13 +53,8 @@ impl Perform for FollowCommunity { let community_id = data.community_id; let person_id = local_user_view.person.id; - let community_view = CommunityView::read( - &mut *context.conn().await?, - community_id, - Some(person_id), - None, - ) - .await?; + let community_view = + CommunityView::read(context.conn().await?, community_id, Some(person_id), None).await?; let discussion_languages = CommunityLanguage::read(context.conn().await?, community_id).await?; Ok(Self::Response { diff --git a/crates/api/src/community/transfer.rs b/crates/api/src/community/transfer.rs index 9800480a1..13b2cdfab 100644 --- a/crates/api/src/community/transfer.rs +++ b/crates/api/src/community/transfer.rs @@ -80,14 +80,10 @@ impl Perform for TransferCommunity { let community_id = data.community_id; let person_id = local_user_view.person.id; - let community_view = CommunityView::read( - &mut *context.conn().await?, - community_id, - Some(person_id), - None, - ) - .await - .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?; + let community_view = + CommunityView::read(context.conn().await?, community_id, Some(person_id), None) + .await + .map_err(|e| LemmyError::from_error_message(e, "couldnt_find_community"))?; let community_id = data.community_id; let moderators = CommunityModeratorView::for_community(context.conn().await?, community_id) diff --git a/crates/api/src/local_user/add_admin.rs b/crates/api/src/local_user/add_admin.rs index cc5eb1b46..386ca0631 100644 --- a/crates/api/src/local_user/add_admin.rs +++ b/crates/api/src/local_user/add_admin.rs @@ -30,7 +30,7 @@ impl Perform for AddAdmin { let added = data.added; let added_person_id = data.person_id; let added_admin = Person::update( - &mut *context.conn().await?, + context.conn().await?, added_person_id, &PersonUpdateForm::builder().admin(Some(added)).build(), ) diff --git a/crates/api/src/local_user/ban_person.rs b/crates/api/src/local_user/ban_person.rs index 410aa1b78..47abfbda6 100644 --- a/crates/api/src/local_user/ban_person.rs +++ b/crates/api/src/local_user/ban_person.rs @@ -37,7 +37,7 @@ impl Perform for BanPerson { let expires = data.expires.map(naive_from_unix); let person = Person::update( - &mut *context.conn().await?, + context.conn().await?, banned_person_id, &PersonUpdateForm::builder() .banned(Some(ban)) @@ -52,7 +52,7 @@ impl Perform for BanPerson { if remove_data { remove_user_data( person.id, - &mut *context.conn().await?, + context.conn().await?, context.settings(), context.client(), ) diff --git a/crates/api/src/local_user/login.rs b/crates/api/src/local_user/login.rs index e72fb6dec..99e910a43 100644 --- a/crates/api/src/local_user/login.rs +++ b/crates/api/src/local_user/login.rs @@ -53,7 +53,7 @@ impl Perform for Login { check_registration_application( &local_user_view, &site_view.local_site, - &mut *context.conn().await?, + context.conn().await?, ) .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 51c1ee64b..895c84b83 100644 --- a/crates/api/src/local_user/notifications/mark_mention_read.rs +++ b/crates/api/src/local_user/notifications/mark_mention_read.rs @@ -34,7 +34,7 @@ impl Perform for MarkPersonMentionAsRead { let person_mention_id = read_person_mention.id; let read = Some(data.read); PersonMention::update( - &mut *context.conn().await?, + context.conn().await?, person_mention_id, &PersonMentionUpdateForm { read }, ) @@ -43,12 +43,8 @@ impl Perform for MarkPersonMentionAsRead { let person_mention_id = read_person_mention.id; let person_id = local_user_view.person.id; - let person_mention_view = PersonMentionView::read( - &mut *context.conn().await?, - person_mention_id, - Some(person_id), - ) - .await?; + let person_mention_view = + PersonMentionView::read(context.conn().await?, person_mention_id, Some(person_id)).await?; Ok(PersonMentionResponse { person_mention_view, 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 c9837940d..70d7f8fe6 100644 --- a/crates/api/src/local_user/notifications/mark_reply_read.rs +++ b/crates/api/src/local_user/notifications/mark_reply_read.rs @@ -35,7 +35,7 @@ impl Perform for MarkCommentReplyAsRead { let read = Some(data.read); CommentReply::update( - &mut *context.conn().await?, + context.conn().await?, comment_reply_id, &CommentReplyUpdateForm { read }, ) @@ -44,12 +44,8 @@ impl Perform for MarkCommentReplyAsRead { let comment_reply_id = read_comment_reply.id; let person_id = local_user_view.person.id; - let comment_reply_view = CommentReplyView::read( - &mut *context.conn().await?, - comment_reply_id, - Some(person_id), - ) - .await?; + let comment_reply_view = + CommentReplyView::read(context.conn().await?, comment_reply_id, Some(person_id)).await?; Ok(CommentReplyResponse { comment_reply_view }) } diff --git a/crates/api/src/local_user/report_count.rs b/crates/api/src/local_user/report_count.rs index cdd082597..25a803cf2 100644 --- a/crates/api/src/local_user/report_count.rs +++ b/crates/api/src/local_user/report_count.rs @@ -24,13 +24,9 @@ impl Perform for GetReportCount { let admin = local_user_view.person.admin; let community_id = data.community_id; - let comment_reports = CommentReportView::get_report_count( - &mut *context.conn().await?, - person_id, - admin, - community_id, - ) - .await?; + let comment_reports = + CommentReportView::get_report_count(context.conn().await?, person_id, admin, community_id) + .await?; let post_reports = PostReportView::get_report_count(context.conn().await?, person_id, admin, community_id) diff --git a/crates/api/src/local_user/reset_password.rs b/crates/api/src/local_user/reset_password.rs index b3f467fad..7ba7b8aac 100644 --- a/crates/api/src/local_user/reset_password.rs +++ b/crates/api/src/local_user/reset_password.rs @@ -28,7 +28,7 @@ impl Perform for PasswordReset { // Check for too many attempts (to limit potential abuse) let recent_resets_count = PasswordResetRequest::get_recent_password_resets_count( - &mut *context.conn().await?, + context.conn().await?, local_user_view.local_user.id, ) .await?; @@ -37,12 +37,7 @@ impl Perform for PasswordReset { } // Email the pure token to the user. - send_password_reset_email( - &local_user_view, - &mut *context.conn().await?, - context.settings(), - ) - .await?; + send_password_reset_email(&local_user_view, context.conn().await?, context.settings()).await?; Ok(PasswordResetResponse {}) } } diff --git a/crates/api/src/local_user/save_settings.rs b/crates/api/src/local_user/save_settings.rs index f35809f92..fe828a005 100644 --- a/crates/api/src/local_user/save_settings.rs +++ b/crates/api/src/local_user/save_settings.rs @@ -52,7 +52,7 @@ impl Perform for SaveUserSettings { send_verification_email( &local_user_view, email, - &mut *context.conn().await?, + context.conn().await?, context.settings(), ) .await?; @@ -100,12 +100,7 @@ impl Perform for SaveUserSettings { .map_err(|e| LemmyError::from_error_message(e, "user_already_exists"))?; if let Some(discussion_languages) = data.discussion_languages.clone() { - LocalUserLanguage::update( - &mut *context.conn().await?, - discussion_languages, - local_user_id, - ) - .await?; + LocalUserLanguage::update(context.conn().await?, discussion_languages, local_user_id).await?; } // If generate_totp is Some(false), this will clear it out from the database. diff --git a/crates/api/src/post/feature.rs b/crates/api/src/post/feature.rs index 6020a88de..ac277264d 100644 --- a/crates/api/src/post/feature.rs +++ b/crates/api/src/post/feature.rs @@ -37,15 +37,15 @@ impl Perform for FeaturePost { check_community_ban( local_user_view.person.id, orig_post.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(orig_post.community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(orig_post.community_id, context.conn().await?).await?; if data.feature_type == PostFeatureType::Community { // Verify that only the mods can feature in community is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, orig_post.community_id, ) diff --git a/crates/api/src/post/like.rs b/crates/api/src/post/like.rs index 31709dcc0..3b1f528b9 100644 --- a/crates/api/src/post/like.rs +++ b/crates/api/src/post/like.rs @@ -41,10 +41,10 @@ impl Perform for CreatePostLike { check_community_ban( local_user_view.person.id, post.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(post.community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(post.community_id, context.conn().await?).await?; let like_form = PostLikeForm { post_id: data.post_id, @@ -66,7 +66,7 @@ impl Perform for CreatePostLike { } // Mark the post as read - mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?; + mark_post_as_read(person_id, post_id, context.conn().await?).await?; build_post_response( context, diff --git a/crates/api/src/post/lock.rs b/crates/api/src/post/lock.rs index beb5cf03c..88d91cf7f 100644 --- a/crates/api/src/post/lock.rs +++ b/crates/api/src/post/lock.rs @@ -35,14 +35,14 @@ impl Perform for LockPost { check_community_ban( local_user_view.person.id, orig_post.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(orig_post.community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(orig_post.community_id, context.conn().await?).await?; // Verify that only the mods can lock is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, orig_post.community_id, ) @@ -52,7 +52,7 @@ impl Perform for LockPost { let post_id = data.post_id; let locked = data.locked; Post::update( - &mut *context.conn().await?, + context.conn().await?, post_id, &PostUpdateForm::builder().locked(Some(locked)).build(), ) diff --git a/crates/api/src/post/mark_read.rs b/crates/api/src/post/mark_read.rs index 8fe8614a7..491e2a104 100644 --- a/crates/api/src/post/mark_read.rs +++ b/crates/api/src/post/mark_read.rs @@ -22,9 +22,9 @@ impl Perform for MarkPostAsRead { // Mark the post as read / unread if data.read { - mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?; + mark_post_as_read(person_id, post_id, context.conn().await?).await?; } else { - mark_post_as_unread(person_id, post_id, &mut *context.conn().await?).await?; + mark_post_as_unread(person_id, post_id, context.conn().await?).await?; } // Fetch it diff --git a/crates/api/src/post/save.rs b/crates/api/src/post/save.rs index 20a7cc8ce..2b6d06889 100644 --- a/crates/api/src/post/save.rs +++ b/crates/api/src/post/save.rs @@ -41,7 +41,7 @@ impl Perform for SavePost { let post_view = PostView::read(context.conn().await?, post_id, Some(person_id), None).await?; // Mark the post as read - mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?; + mark_post_as_read(person_id, post_id, context.conn().await?).await?; Ok(PostResponse { post_view }) } diff --git a/crates/api/src/post_report/create.rs b/crates/api/src/post_report/create.rs index 7084a11ac..b3ec72a38 100644 --- a/crates/api/src/post_report/create.rs +++ b/crates/api/src/post_report/create.rs @@ -33,12 +33,7 @@ impl Perform for CreatePostReport { let post_id = data.post_id; let post_view = PostView::read(context.conn().await?, post_id, None, None).await?; - check_community_ban( - person_id, - post_view.community.id, - &mut *context.conn().await?, - ) - .await?; + check_community_ban(person_id, post_view.community.id, context.conn().await?).await?; let report_form = PostReportForm { creator_id: person_id, @@ -61,7 +56,7 @@ impl Perform for CreatePostReport { send_new_report_email_to_admins( &post_report_view.creator.name, &post_report_view.post_creator.name, - &mut *context.conn().await?, + context.conn().await?, context.settings(), ) .await?; diff --git a/crates/api/src/private_message/mark_read.rs b/crates/api/src/private_message/mark_read.rs index 61aa2e718..1cc268c47 100644 --- a/crates/api/src/private_message/mark_read.rs +++ b/crates/api/src/private_message/mark_read.rs @@ -36,7 +36,7 @@ impl Perform for MarkPrivateMessageAsRead { let private_message_id = data.private_message_id; let read = data.read; PrivateMessage::update( - &mut *context.conn().await?, + context.conn().await?, private_message_id, &PrivateMessageUpdateForm::builder().read(Some(read)).build(), ) diff --git a/crates/api/src/private_message_report/create.rs b/crates/api/src/private_message_report/create.rs index cc824e3c5..50dfd928b 100644 --- a/crates/api/src/private_message_report/create.rs +++ b/crates/api/src/private_message_report/create.rs @@ -51,7 +51,7 @@ impl Perform for CreatePrivateMessageReport { send_new_report_email_to_admins( &private_message_report_view.creator.name, &private_message_report_view.private_message_creator.name, - &mut *context.conn().await?, + context.conn().await?, context.settings(), ) .await?; diff --git a/crates/api/src/site/leave_admin.rs b/crates/api/src/site/leave_admin.rs index 02b8e7f05..d145bfec9 100644 --- a/crates/api/src/site/leave_admin.rs +++ b/crates/api/src/site/leave_admin.rs @@ -38,7 +38,7 @@ impl Perform for LeaveAdmin { let person_id = local_user_view.person.id; Person::update( - &mut *context.conn().await?, + context.conn().await?, person_id, &PersonUpdateForm::builder().admin(Some(false)).build(), ) diff --git a/crates/api/src/site/mod_log.rs b/crates/api/src/site/mod_log.rs index 1ae6ac1b0..192ef09fe 100644 --- a/crates/api/src/site/mod_log.rs +++ b/crates/api/src/site/mod_log.rs @@ -56,13 +56,9 @@ impl Perform for GetModlog { None => CommunityId(-1), }; let is_mod_of_community = data.community_id.is_some() - && is_mod_or_admin( - &mut *context.conn().await?, - local_person_id, - community_id_value, - ) - .await - .is_ok(); + && is_mod_or_admin(context.conn().await?, local_person_id, community_id_value) + .await + .is_ok(); let hide_modlog_names = local_site.hide_modlog_mod_names && !is_mod_of_community && !is_admin; let mod_person_id = if hide_modlog_names { diff --git a/crates/api/src/site/purge/community.rs b/crates/api/src/site/purge/community.rs index e904fc95d..e151650e0 100644 --- a/crates/api/src/site/purge/community.rs +++ b/crates/api/src/site/purge/community.rs @@ -46,7 +46,7 @@ impl Perform for PurgeCommunity { purge_image_posts_for_community( community_id, - &mut *context.conn().await?, + context.conn().await?, context.settings(), context.client(), ) diff --git a/crates/api/src/site/purge/person.rs b/crates/api/src/site/purge/person.rs index 0f8a0a25f..f38dda7eb 100644 --- a/crates/api/src/site/purge/person.rs +++ b/crates/api/src/site/purge/person.rs @@ -45,7 +45,7 @@ impl Perform for PurgePerson { purge_image_posts_for_person( person_id, - &mut *context.conn().await?, + context.conn().await?, context.settings(), context.client(), ) diff --git a/crates/api/src/site/registration_applications/approve.rs b/crates/api/src/site/registration_applications/approve.rs index 59193e7b6..e13efeee6 100644 --- a/crates/api/src/site/registration_applications/approve.rs +++ b/crates/api/src/site/registration_applications/approve.rs @@ -45,12 +45,7 @@ impl Perform for ApproveRegistrationApplication { .build(); let approved_user_id = registration_application.local_user_id; - LocalUser::update( - &mut *context.conn().await?, - approved_user_id, - &local_user_form, - ) - .await?; + LocalUser::update(context.conn().await?, approved_user_id, &local_user_form).await?; if data.approve { let approved_local_user_view = diff --git a/crates/api/src/site/registration_applications/unread_count.rs b/crates/api/src/site/registration_applications/unread_count.rs index 02ee033d4..666104635 100644 --- a/crates/api/src/site/registration_applications/unread_count.rs +++ b/crates/api/src/site/registration_applications/unread_count.rs @@ -23,11 +23,9 @@ impl Perform for GetUnreadRegistrationApplicationCount { let verified_email_only = local_site.require_email_verification; - let registration_applications = RegistrationApplicationView::get_unread_count( - &mut *context.conn().await?, - verified_email_only, - ) - .await?; + let registration_applications = + RegistrationApplicationView::get_unread_count(context.conn().await?, verified_email_only) + .await?; Ok(Self::Response { registration_applications, diff --git a/crates/api_common/src/build_response.rs b/crates/api_common/src/build_response.rs index c9c3e440d..4fd9e6a93 100644 --- a/crates/api_common/src/build_response.rs +++ b/crates/api_common/src/build_response.rs @@ -44,7 +44,7 @@ pub async fn build_community_response( community_id: CommunityId, ) -> Result { let is_mod_or_admin = is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, community_id, ) @@ -52,7 +52,7 @@ pub async fn build_community_response( .is_ok(); let person_id = local_user_view.person.id; let community_view = CommunityView::read( - &mut *context.conn().await?, + context.conn().await?, community_id, Some(person_id), Some(is_mod_or_admin), @@ -76,7 +76,7 @@ pub async fn build_post_response( .await .is_ok(); let post_view = PostView::read( - &mut *context.conn().await?, + context.conn().await?, post_id, Some(person_id), Some(is_mod_or_admin), @@ -144,10 +144,9 @@ pub async fn send_local_notifs( let parent_creator_id = parent_comment.creator_id; // Only add to recipients if that person isn't blocked - let creator_blocked = - check_person_block(person.id, parent_creator_id, &mut *context.conn().await?) - .await - .is_err(); + let creator_blocked = check_person_block(person.id, parent_creator_id, context.conn().await?) + .await + .is_err(); // Don't send a notif to yourself if parent_comment.creator_id != person.id && !creator_blocked { @@ -181,10 +180,9 @@ pub async fn send_local_notifs( } else { // If there's no parent, its the post creator // Only add to recipients if that person isn't blocked - let creator_blocked = - check_person_block(person.id, post.creator_id, &mut *context.conn().await?) - .await - .is_err(); + let creator_blocked = check_person_block(person.id, post.creator_id, context.conn().await?) + .await + .is_err(); if post.creator_id != person.id && !creator_blocked { let creator_id = post.creator_id; diff --git a/crates/api_crud/src/comment/create.rs b/crates/api_crud/src/comment/create.rs index db9dfc8ff..c834414e4 100644 --- a/crates/api_crud/src/comment/create.rs +++ b/crates/api_crud/src/comment/create.rs @@ -53,16 +53,16 @@ impl PerformCrud for CreateComment { // Check for a community ban let post_id = data.post_id; - let post = get_post(post_id, &mut *context.conn().await?).await?; + let post = get_post(post_id, context.conn().await?).await?; let community_id = post.community_id; check_community_ban( local_user_view.person.id, community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(community_id, context.conn().await?).await?; check_post_deleted_or_removed(&post)?; // Check if post is locked, no new comments @@ -94,7 +94,7 @@ impl PerformCrud for CreateComment { let language_id = data.language_id.unwrap_or(parent_language); CommunityLanguage::is_allowed_community_language( - &mut *context.conn().await?, + context.conn().await?, Some(language_id), community_id, ) @@ -109,13 +109,10 @@ impl PerformCrud for CreateComment { // Create the comment let parent_path = parent_opt.clone().map(|t| t.path); - let inserted_comment = Comment::create( - &mut *context.conn().await?, - &comment_form, - parent_path.as_ref(), - ) - .await - .map_err(|e| LemmyError::from_error_message(e, "couldnt_create_comment"))?; + let inserted_comment = + Comment::create(context.conn().await?, &comment_form, parent_path.as_ref()) + .await + .map_err(|e| LemmyError::from_error_message(e, "couldnt_create_comment"))?; // Necessary to update the ap_id let inserted_comment_id = inserted_comment.id; @@ -127,7 +124,7 @@ impl PerformCrud for CreateComment { &protocol_and_hostname, )?; let updated_comment = Comment::update( - &mut *context.conn().await?, + context.conn().await?, inserted_comment_id, &CommentUpdateForm::builder().ap_id(Some(apub_id)).build(), ) @@ -164,7 +161,7 @@ impl PerformCrud for CreateComment { let comment_reply = CommentReply::read_by_comment(context.conn().await?, parent_id).await; if let Ok(reply) = comment_reply { CommentReply::update( - &mut *context.conn().await?, + context.conn().await?, reply.id, &CommentReplyUpdateForm { read: Some(true) }, ) @@ -174,15 +171,12 @@ impl PerformCrud for CreateComment { // If the parent has PersonMentions mark them as read too let person_id = local_user_view.person.id; - let person_mention = PersonMention::read_by_comment_and_person( - &mut *context.conn().await?, - parent_id, - person_id, - ) - .await; + let person_mention = + PersonMention::read_by_comment_and_person(context.conn().await?, parent_id, person_id) + .await; if let Ok(mention) = person_mention { PersonMention::update( - &mut *context.conn().await?, + context.conn().await?, mention.id, &PersonMentionUpdateForm { read: Some(true) }, ) diff --git a/crates/api_crud/src/comment/delete.rs b/crates/api_crud/src/comment/delete.rs index f62b13730..9a07543cb 100644 --- a/crates/api_crud/src/comment/delete.rs +++ b/crates/api_crud/src/comment/delete.rs @@ -36,7 +36,7 @@ impl PerformCrud for DeleteComment { check_community_ban( local_user_view.person.id, orig_comment.community.id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; @@ -48,7 +48,7 @@ impl PerformCrud for DeleteComment { // Do the delete let deleted = data.deleted; let updated_comment = Comment::update( - &mut *context.conn().await?, + context.conn().await?, comment_id, &CommentUpdateForm::builder().deleted(Some(deleted)).build(), ) diff --git a/crates/api_crud/src/comment/remove.rs b/crates/api_crud/src/comment/remove.rs index 05e40e023..0bf879d30 100644 --- a/crates/api_crud/src/comment/remove.rs +++ b/crates/api_crud/src/comment/remove.rs @@ -32,13 +32,13 @@ impl PerformCrud for RemoveComment { check_community_ban( local_user_view.person.id, orig_comment.community.id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; // Verify that only a mod or admin can remove is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, orig_comment.community.id, ) @@ -47,7 +47,7 @@ impl PerformCrud for RemoveComment { // Do the remove let removed = data.removed; let updated_comment = Comment::update( - &mut *context.conn().await?, + context.conn().await?, comment_id, &CommentUpdateForm::builder().removed(Some(removed)).build(), ) diff --git a/crates/api_crud/src/comment/update.rs b/crates/api_crud/src/comment/update.rs index 9a60ef3cb..37881e6ea 100644 --- a/crates/api_crud/src/comment/update.rs +++ b/crates/api_crud/src/comment/update.rs @@ -41,7 +41,7 @@ impl PerformCrud for EditComment { check_community_ban( local_user_view.person.id, orig_comment.community.id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; @@ -52,7 +52,7 @@ impl PerformCrud for EditComment { let language_id = self.language_id; CommunityLanguage::is_allowed_community_language( - &mut *context.conn().await?, + context.conn().await?, language_id, orig_comment.community.id, ) diff --git a/crates/api_crud/src/community/delete.rs b/crates/api_crud/src/community/delete.rs index f29d9788a..fd888f1a8 100644 --- a/crates/api_crud/src/community/delete.rs +++ b/crates/api_crud/src/community/delete.rs @@ -34,7 +34,7 @@ impl PerformCrud for DeleteCommunity { let community_id = data.community_id; let deleted = data.deleted; Community::update( - &mut *context.conn().await?, + context.conn().await?, community_id, &CommunityUpdateForm::builder() .deleted(Some(deleted)) diff --git a/crates/api_crud/src/community/remove.rs b/crates/api_crud/src/community/remove.rs index d187781dc..bf82dfe02 100644 --- a/crates/api_crud/src/community/remove.rs +++ b/crates/api_crud/src/community/remove.rs @@ -31,7 +31,7 @@ impl PerformCrud for RemoveCommunity { let community_id = data.community_id; let removed = data.removed; Community::update( - &mut *context.conn().await?, + context.conn().await?, community_id, &CommunityUpdateForm::builder() .removed(Some(removed)) diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index 57e8a0899..1458a1384 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -62,17 +62,17 @@ impl PerformCrud for CreatePost { check_community_ban( local_user_view.person.id, data.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(data.community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(data.community_id, context.conn().await?).await?; let community_id = data.community_id; let community = Community::read(context.conn().await?, community_id).await?; if community.posting_restricted_to_mods { let community_id = data.community_id; let is_mod = CommunityView::is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.local_user.person_id, community_id, ) @@ -93,7 +93,7 @@ impl PerformCrud for CreatePost { Some(lid) => Some(lid), None => { default_post_language( - &mut *context.conn().await?, + context.conn().await?, community_id, local_user_view.local_user.id, ) @@ -101,7 +101,7 @@ impl PerformCrud for CreatePost { } }; CommunityLanguage::is_allowed_community_language( - &mut *context.conn().await?, + context.conn().await?, language_id, community_id, ) @@ -142,7 +142,7 @@ impl PerformCrud for CreatePost { &protocol_and_hostname, )?; let updated_post = Post::update( - &mut *context.conn().await?, + context.conn().await?, inserted_post_id, &PostUpdateForm::builder().ap_id(Some(apub_id)).build(), ) @@ -163,7 +163,7 @@ impl PerformCrud for CreatePost { .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?; // Mark the post as read - mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?; + mark_post_as_read(person_id, post_id, context.conn().await?).await?; if let Some(url) = &updated_post.url { let mut webmention = diff --git a/crates/api_crud/src/post/delete.rs b/crates/api_crud/src/post/delete.rs index 9a7c49e65..3802b39ed 100644 --- a/crates/api_crud/src/post/delete.rs +++ b/crates/api_crud/src/post/delete.rs @@ -32,10 +32,10 @@ impl PerformCrud for DeletePost { check_community_ban( local_user_view.person.id, orig_post.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; - check_community_deleted_or_removed(orig_post.community_id, &mut *context.conn().await?).await?; + check_community_deleted_or_removed(orig_post.community_id, context.conn().await?).await?; // Verify that only the creator can delete if !Post::is_post_creator(local_user_view.person.id, orig_post.creator_id) { @@ -46,7 +46,7 @@ impl PerformCrud for DeletePost { let post_id = data.post_id; let deleted = data.deleted; Post::update( - &mut *context.conn().await?, + context.conn().await?, post_id, &PostUpdateForm::builder().deleted(Some(deleted)).build(), ) diff --git a/crates/api_crud/src/post/read.rs b/crates/api_crud/src/post/read.rs index d4e447a84..1b8b610bd 100644 --- a/crates/api_crud/src/post/read.rs +++ b/crates/api_crud/src/post/read.rs @@ -50,7 +50,7 @@ impl PerformCrud for GetPost { .await? .community_id; let is_mod_or_admin = is_mod_or_admin_opt( - &mut *context.conn().await?, + context.conn().await?, local_user_view.as_ref(), Some(community_id), ) @@ -58,7 +58,7 @@ impl PerformCrud for GetPost { .is_ok(); let post_view = PostView::read( - &mut *context.conn().await?, + context.conn().await?, post_id, person_id, Some(is_mod_or_admin), @@ -69,12 +69,12 @@ impl PerformCrud for GetPost { // Mark the post as read let post_id = post_view.post.id; if let Some(person_id) = person_id { - mark_post_as_read(person_id, post_id, &mut *context.conn().await?).await?; + mark_post_as_read(person_id, post_id, context.conn().await?).await?; } // Necessary for the sidebar subscribed let community_view = CommunityView::read( - &mut *context.conn().await?, + context.conn().await?, community_id, person_id, Some(is_mod_or_admin), diff --git a/crates/api_crud/src/post/remove.rs b/crates/api_crud/src/post/remove.rs index d88ea1512..97681154d 100644 --- a/crates/api_crud/src/post/remove.rs +++ b/crates/api_crud/src/post/remove.rs @@ -30,13 +30,13 @@ impl PerformCrud for RemovePost { check_community_ban( local_user_view.person.id, orig_post.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; // Verify that only the mods can remove is_mod_or_admin( - &mut *context.conn().await?, + context.conn().await?, local_user_view.person.id, orig_post.community_id, ) @@ -46,7 +46,7 @@ impl PerformCrud for RemovePost { let post_id = data.post_id; let removed = data.removed; Post::update( - &mut *context.conn().await?, + context.conn().await?, post_id, &PostUpdateForm::builder().removed(Some(removed)).build(), ) diff --git a/crates/api_crud/src/post/update.rs b/crates/api_crud/src/post/update.rs index 2bc6da787..08aef04be 100644 --- a/crates/api_crud/src/post/update.rs +++ b/crates/api_crud/src/post/update.rs @@ -57,7 +57,7 @@ impl PerformCrud for EditPost { check_community_ban( local_user_view.person.id, orig_post.community_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; @@ -76,7 +76,7 @@ impl PerformCrud for EditPost { let language_id = self.language_id; CommunityLanguage::is_allowed_community_language( - &mut *context.conn().await?, + context.conn().await?, language_id, orig_post.community_id, ) diff --git a/crates/api_crud/src/private_message/create.rs b/crates/api_crud/src/private_message/create.rs index 7c37f6743..f5839b03b 100644 --- a/crates/api_crud/src/private_message/create.rs +++ b/crates/api_crud/src/private_message/create.rs @@ -48,7 +48,7 @@ impl PerformCrud for CreatePrivateMessage { check_person_block( local_user_view.person.id, data.recipient_id, - &mut *context.conn().await?, + context.conn().await?, ) .await?; @@ -77,7 +77,7 @@ impl PerformCrud for CreatePrivateMessage { &protocol_and_hostname, )?; PrivateMessage::update( - &mut *context.conn().await?, + context.conn().await?, inserted_private_message.id, &PrivateMessageUpdateForm::builder() .ap_id(Some(apub_id)) diff --git a/crates/api_crud/src/private_message/delete.rs b/crates/api_crud/src/private_message/delete.rs index b5c49b442..1990fec9c 100644 --- a/crates/api_crud/src/private_message/delete.rs +++ b/crates/api_crud/src/private_message/delete.rs @@ -36,7 +36,7 @@ impl PerformCrud for DeletePrivateMessage { let private_message_id = data.private_message_id; let deleted = data.deleted; PrivateMessage::update( - &mut *context.conn().await?, + context.conn().await?, private_message_id, &PrivateMessageUpdateForm::builder() .deleted(Some(deleted)) diff --git a/crates/api_crud/src/private_message/update.rs b/crates/api_crud/src/private_message/update.rs index 86c0568b0..e28c22ffb 100644 --- a/crates/api_crud/src/private_message/update.rs +++ b/crates/api_crud/src/private_message/update.rs @@ -46,7 +46,7 @@ impl PerformCrud for EditPrivateMessage { let private_message_id = data.private_message_id; PrivateMessage::update( - &mut *context.conn().await?, + context.conn().await?, private_message_id, &PrivateMessageUpdateForm::builder() .content(Some(content_slurs_removed)) diff --git a/crates/api_crud/src/site/update.rs b/crates/api_crud/src/site/update.rs index 4f41c4208..666220bc7 100644 --- a/crates/api_crud/src/site/update.rs +++ b/crates/api_crud/src/site/update.rs @@ -56,12 +56,7 @@ impl PerformCrud for EditSite { validate_update_payload(&local_site, data)?; if let Some(discussion_languages) = data.discussion_languages.clone() { - SiteLanguage::update( - &mut *context.conn().await?, - discussion_languages.clone(), - &site, - ) - .await?; + SiteLanguage::update(context.conn().await?, discussion_languages.clone(), &site).await?; } let site_form = SiteUpdateForm::builder() diff --git a/crates/api_crud/src/user/create.rs b/crates/api_crud/src/user/create.rs index 7f7957645..6c729ca13 100644 --- a/crates/api_crud/src/user/create.rs +++ b/crates/api_crud/src/user/create.rs @@ -76,7 +76,7 @@ impl PerformCrud for Register { if let Some(captcha_uuid) = &data.captcha_uuid { let uuid = uuid::Uuid::parse_str(captcha_uuid)?; let check = CaptchaAnswer::check_captcha( - &mut *context.conn().await?, + context.conn().await?, CheckCaptchaAnswer { uuid, answer: data.captcha_answer.clone().unwrap_or_default(), @@ -157,12 +157,8 @@ impl PerformCrud for Register { // Email the admins if local_site.application_email_admins { - send_new_applicant_email_to_admins( - &data.username, - &mut *context.conn().await?, - context.settings(), - ) - .await?; + send_new_applicant_email_to_admins(&data.username, context.conn().await?, context.settings()) + .await?; } let mut login_response = LoginResponse { @@ -200,7 +196,7 @@ impl PerformCrud for Register { send_verification_email( &local_user_view, &email, - &mut *context.conn().await?, + context.conn().await?, context.settings(), ) .await?; diff --git a/crates/apub/src/activities/block/block_user.rs b/crates/apub/src/activities/block/block_user.rs index 2442564bc..dd5e05411 100644 --- a/crates/apub/src/activities/block/block_user.rs +++ b/crates/apub/src/activities/block/block_user.rs @@ -60,7 +60,7 @@ impl BlockUser { actor: mod_.id().into(), to: vec![public()], object: user.id().into(), - cc: generate_cc(target, &mut *context.conn().await?).await?, + cc: generate_cc(target, context.conn().await?).await?, target: target.id(), kind: BlockType::Block, remove_data, @@ -155,7 +155,7 @@ impl ActivityHandler for BlockUser { match target { SiteOrCommunity::Site(_site) => { let blocked_person = Person::update( - &mut *context.conn().await?, + context.conn().await?, blocked_person.id, &PersonUpdateForm::builder() .banned(Some(true)) @@ -166,7 +166,7 @@ impl ActivityHandler for BlockUser { if self.remove_data.unwrap_or(false) { remove_user_data( blocked_person.id, - &mut *context.conn().await?, + context.conn().await?, context.settings(), context.client(), ) @@ -202,12 +202,8 @@ impl ActivityHandler for BlockUser { .ok(); if self.remove_data.unwrap_or(false) { - remove_user_data_in_community( - community.id, - blocked_person.id, - &mut *context.conn().await?, - ) - .await?; + remove_user_data_in_community(community.id, blocked_person.id, context.conn().await?) + .await?; } // write to mod log diff --git a/crates/apub/src/activities/block/undo_block_user.rs b/crates/apub/src/activities/block/undo_block_user.rs index 592dc8ffa..f1a15cb0b 100644 --- a/crates/apub/src/activities/block/undo_block_user.rs +++ b/crates/apub/src/activities/block/undo_block_user.rs @@ -53,7 +53,7 @@ impl UndoBlockUser { actor: mod_.id().into(), to: vec![public()], object: block, - cc: generate_cc(target, &mut *context.conn().await?).await?, + cc: generate_cc(target, context.conn().await?).await?, kind: UndoType::Undo, id: id.clone(), audience, @@ -103,7 +103,7 @@ impl ActivityHandler for UndoBlockUser { match self.object.target.dereference(context).await? { SiteOrCommunity::Site(_site) => { let blocked_person = Person::update( - &mut *context.conn().await?, + context.conn().await?, blocked_person.id, &PersonUpdateForm::builder() .banned(Some(false)) diff --git a/crates/apub/src/activities/community/collection_add.rs b/crates/apub/src/activities/community/collection_add.rs index 96ac8f99f..8ceba20e7 100644 --- a/crates/apub/src/activities/community/collection_add.rs +++ b/crates/apub/src/activities/community/collection_add.rs @@ -129,11 +129,9 @@ impl ActivityHandler for CollectionAdd { // If we had to refetch the community while parsing the activity, then the new mod has already // been added. Skip it here as it would result in a duplicate key error. let new_mod_id = new_mod.id; - let moderated_communities = CommunityModerator::get_person_moderated_communities( - &mut *context.conn().await?, - new_mod_id, - ) - .await?; + let moderated_communities = + CommunityModerator::get_person_moderated_communities(context.conn().await?, new_mod_id) + .await?; if !moderated_communities.contains(&community.id) { let form = CommunityModeratorForm { community_id: community.id, diff --git a/crates/apub/src/activities/community/update.rs b/crates/apub/src/activities/community/update.rs index 6eaa09e0b..f5f10aa18 100644 --- a/crates/apub/src/activities/community/update.rs +++ b/crates/apub/src/activities/community/update.rs @@ -97,12 +97,7 @@ impl ActivityHandler for UpdateCommunity { let community_update_form = self.object.into_update_form(); - Community::update( - &mut *context.conn().await?, - community.id, - &community_update_form, - ) - .await?; + Community::update(context.conn().await?, community.id, &community_update_form).await?; Ok(()) } } diff --git a/crates/apub/src/activities/deletion/delete.rs b/crates/apub/src/activities/deletion/delete.rs index d2305aa77..56fd1e885 100644 --- a/crates/apub/src/activities/deletion/delete.rs +++ b/crates/apub/src/activities/deletion/delete.rs @@ -121,7 +121,7 @@ pub(in crate::activities) async fn receive_remove_action( }; ModRemoveCommunity::create(context.conn().await?, &form).await?; Community::update( - &mut *context.conn().await?, + context.conn().await?, community.id, &CommunityUpdateForm::builder().removed(Some(true)).build(), ) @@ -136,7 +136,7 @@ pub(in crate::activities) async fn receive_remove_action( }; ModRemovePost::create(context.conn().await?, &form).await?; Post::update( - &mut *context.conn().await?, + context.conn().await?, post.id, &PostUpdateForm::builder().removed(Some(true)).build(), ) @@ -151,7 +151,7 @@ pub(in crate::activities) async fn receive_remove_action( }; ModRemoveComment::create(context.conn().await?, &form).await?; Comment::update( - &mut *context.conn().await?, + context.conn().await?, comment.id, &CommentUpdateForm::builder().removed(Some(true)).build(), ) diff --git a/crates/apub/src/activities/deletion/delete_user.rs b/crates/apub/src/activities/deletion/delete_user.rs index 1c2264f92..572b804dd 100644 --- a/crates/apub/src/activities/deletion/delete_user.rs +++ b/crates/apub/src/activities/deletion/delete_user.rs @@ -32,7 +32,7 @@ impl SendActivity for DeleteAccount { let actor: ApubPerson = local_user_view.person.into(); delete_user_account( actor.id, - &mut *context.conn().await?, + context.conn().await?, context.settings(), context.client(), ) @@ -84,7 +84,7 @@ impl ActivityHandler for DeleteUser { let actor = self.actor.dereference(context).await?; delete_user_account( actor.id, - &mut *context.conn().await?, + context.conn().await?, context.settings(), context.client(), ) diff --git a/crates/apub/src/activities/deletion/mod.rs b/crates/apub/src/activities/deletion/mod.rs index d1d65500c..35a1c8d96 100644 --- a/crates/apub/src/activities/deletion/mod.rs +++ b/crates/apub/src/activities/deletion/mod.rs @@ -113,11 +113,7 @@ impl SendActivity for DeleteComment { ) -> Result<(), LemmyError> { let community_id = response.comment_view.community.id; let community = Community::read(context.conn().await?, community_id).await?; - let person = Person::read( - &mut *context.conn().await?, - response.comment_view.creator.id, - ) - .await?; + let person = Person::read(context.conn().await?, response.comment_view.creator.id).await?; let deletable = DeletableObjects::Comment(response.comment_view.comment.clone().into()); send_apub_delete_in_community(person, community, deletable, None, request.deleted, context) .await @@ -135,11 +131,8 @@ impl SendActivity for RemoveComment { ) -> Result<(), LemmyError> { let local_user_view = local_user_view_from_jwt(&request.auth, context).await?; let comment = Comment::read(context.conn().await?, request.comment_id).await?; - let community = Community::read( - &mut *context.conn().await?, - response.comment_view.community.id, - ) - .await?; + let community = + Community::read(context.conn().await?, response.comment_view.community.id).await?; let deletable = DeletableObjects::Comment(comment.into()); send_apub_delete_in_community( local_user_view.person, @@ -398,7 +391,7 @@ async fn receive_delete_action( } Community::update( - &mut *context.conn().await?, + context.conn().await?, community.id, &CommunityUpdateForm::builder() .deleted(Some(deleted)) @@ -409,7 +402,7 @@ async fn receive_delete_action( DeletableObjects::Post(post) => { if deleted != post.deleted { Post::update( - &mut *context.conn().await?, + context.conn().await?, post.id, &PostUpdateForm::builder().deleted(Some(deleted)).build(), ) @@ -419,7 +412,7 @@ async fn receive_delete_action( DeletableObjects::Comment(comment) => { if deleted != comment.deleted { Comment::update( - &mut *context.conn().await?, + context.conn().await?, comment.id, &CommentUpdateForm::builder().deleted(Some(deleted)).build(), ) @@ -428,7 +421,7 @@ async fn receive_delete_action( } DeletableObjects::PrivateMessage(pm) => { PrivateMessage::update( - &mut *context.conn().await?, + context.conn().await?, pm.id, &PrivateMessageUpdateForm::builder() .deleted(Some(deleted)) diff --git a/crates/apub/src/activities/deletion/undo_delete.rs b/crates/apub/src/activities/deletion/undo_delete.rs index be13d9d52..916a36fa7 100644 --- a/crates/apub/src/activities/deletion/undo_delete.rs +++ b/crates/apub/src/activities/deletion/undo_delete.rs @@ -113,7 +113,7 @@ impl UndoDelete { }; ModRemoveCommunity::create(context.conn().await?, &form).await?; Community::update( - &mut *context.conn().await?, + context.conn().await?, community.id, &CommunityUpdateForm::builder().removed(Some(false)).build(), ) @@ -128,7 +128,7 @@ impl UndoDelete { }; ModRemovePost::create(context.conn().await?, &form).await?; Post::update( - &mut *context.conn().await?, + context.conn().await?, post.id, &PostUpdateForm::builder().removed(Some(false)).build(), ) @@ -143,7 +143,7 @@ impl UndoDelete { }; ModRemoveComment::create(context.conn().await?, &form).await?; Comment::update( - &mut *context.conn().await?, + context.conn().await?, comment.id, &CommentUpdateForm::builder().removed(Some(false)).build(), ) diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index bd8889a5e..58520c870 100644 --- a/crates/apub/src/api/list_posts.rs +++ b/crates/apub/src/api/list_posts.rs @@ -42,7 +42,7 @@ impl PerformApub for GetPosts { let listing_type = listing_type_with_default(data.type_, &local_site, community_id)?; let is_mod_or_admin = is_mod_or_admin_opt( - &mut *context.conn().await?, + context.conn().await?, local_user_view.as_ref(), community_id, ) diff --git a/crates/apub/src/api/read_community.rs b/crates/apub/src/api/read_community.rs index e34be994a..cbef03bb9 100644 --- a/crates/apub/src/api/read_community.rs +++ b/crates/apub/src/api/read_community.rs @@ -51,7 +51,7 @@ impl PerformApub for GetCommunity { }; let is_mod_or_admin = is_mod_or_admin_opt( - &mut *context.conn().await?, + context.conn().await?, local_user_view.as_ref(), Some(community_id), ) @@ -59,7 +59,7 @@ impl PerformApub for GetCommunity { .is_ok(); let community_view = CommunityView::read( - &mut *context.conn().await?, + context.conn().await?, community_id, person_id, Some(is_mod_or_admin), diff --git a/crates/apub/src/api/resolve_object.rs b/crates/apub/src/api/resolve_object.rs index 34d195ed7..c57e35ecb 100644 --- a/crates/apub/src/api/resolve_object.rs +++ b/crates/apub/src/api/resolve_object.rs @@ -31,7 +31,7 @@ impl PerformApub for ResolveObject { let res = search_query_to_object_id(&self.q, context) .await .map_err(|e| e.with_message("couldnt_find_object"))?; - convert_response(res, person_id, &mut *context.conn().await?) + convert_response(res, person_id, context.conn().await?) .await .map_err(|e| e.with_message("couldnt_find_object")) } diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index bc3c6bd19..cd57a63ac 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -129,12 +129,10 @@ mod tests { let community = parse_lemmy_community(&context).await; let community_id = community.id; - let inserted_instance = Instance::read_or_create( - &mut *context.conn().await.unwrap(), - "my_domain.tld".to_string(), - ) - .await - .unwrap(); + let inserted_instance = + Instance::read_or_create(context.conn().await.unwrap(), "my_domain.tld".to_string()) + .await + .unwrap(); let old_mod = PersonInsertForm::builder() .name("holly".into()) @@ -150,12 +148,9 @@ mod tests { person_id: old_mod.id, }; - CommunityModerator::join( - &mut *context.conn().await.unwrap(), - &community_moderator_form, - ) - .await - .unwrap(); + CommunityModerator::join(context.conn().await.unwrap(), &community_moderator_form) + .await + .unwrap(); assert_eq!(site.actor_id.to_string(), "https://enterprise.lemmy.ml/"); diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 2ac125479..2c00e6329 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -98,7 +98,7 @@ impl Object for ApubComment { } else { post.ap_id.into() }; - let language = LanguageTag::new_single(self.language_id, &mut *context.conn().await?).await?; + let language = LanguageTag::new_single(self.language_id, context.conn().await?).await?; let maa = collect_non_local_mentions(&self, community.actor_id.clone().into(), context).await?; let note = Note { @@ -163,7 +163,7 @@ impl Object for ApubComment { let slur_regex = &local_site_opt_to_slur_regex(&local_site); let content_slurs_removed = remove_slurs(&content, slur_regex); let language_id = - LanguageTag::to_language_id_single(note.language, &mut *context.conn().await?).await?; + LanguageTag::to_language_id_single(note.language, context.conn().await?).await?; let form = CommentInsertForm { creator_id: creator.id, @@ -179,12 +179,8 @@ impl Object for ApubComment { language_id, }; let parent_comment_path = parent_comment.map(|t| t.0.path); - let comment = Comment::create( - &mut *context.conn().await?, - &form, - parent_comment_path.as_ref(), - ) - .await?; + let comment = + Comment::create(context.conn().await?, &form, parent_comment_path.as_ref()).await?; Ok(comment.into()) } } diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 069b94177..64043f225 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -132,7 +132,7 @@ impl Object for ApubCommunity { let form = Group::into_insert_form(group.clone(), instance_id); let languages = - LanguageTag::to_language_id_multiple(group.language, &mut *context.conn().await?).await?; + LanguageTag::to_language_id_multiple(group.language, context.conn().await?).await?; let community = Community::create(context.conn().await?, &form).await?; CommunityLanguage::update(context.conn().await?, languages, community.id).await?; diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index 03c5d2878..e0e405902 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -105,7 +105,7 @@ impl Object for ApubPost { let creator = Person::read(context.conn().await?, creator_id).await?; let community_id = self.community_id; let community = Community::read(context.conn().await?, community_id).await?; - let language = LanguageTag::new_single(self.language_id, &mut *context.conn().await?).await?; + let language = LanguageTag::new_single(self.language_id, context.conn().await?).await?; let page = Page { kind: PageType::Page, @@ -230,7 +230,7 @@ impl Object for ApubPost { read_from_string_or_source_opt(&page.content, &page.media_type, &page.source) .map(|s| remove_slurs(&s, slur_regex)); let language_id = - LanguageTag::to_language_id_single(page.language, &mut *context.conn().await?).await?; + LanguageTag::to_language_id_single(page.language, context.conn().await?).await?; PostInsertForm { name, diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index db333f270..083cf01eb 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -124,7 +124,7 @@ impl Object for ApubPrivateMessage { ) -> Result { let creator = note.attributed_to.dereference(context).await?; let recipient = note.to[0].dereference(context).await?; - check_person_block(creator.id, recipient.id, &mut *context.conn().await?).await?; + check_person_block(creator.id, recipient.id, context.conn().await?).await?; let form = PrivateMessageInsertForm { creator_id: creator.id, diff --git a/crates/db_schema/src/utils.rs b/crates/db_schema/src/utils.rs index 9dcfb3751..57baa4ce1 100644 --- a/crates/db_schema/src/utils.rs +++ b/crates/db_schema/src/utils.rs @@ -23,7 +23,6 @@ use diesel_async::{ deadpool::{Object as PooledConnection, Pool}, AsyncDieselConnectionManager, }, - AsyncConnection, }; use diesel_migrations::EmbeddedMigrations; use futures_util::{future::BoxFuture, FutureExt}; diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index af42bf072..229c24ab9 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -179,7 +179,7 @@ async fn get_feed( let builder = match request_type { RequestType::User => { get_feed_user( - &mut *context.conn().await?, + context.conn().await?, &info.sort_type()?, &info.get_limit(), &info.get_page(), @@ -190,7 +190,7 @@ async fn get_feed( } RequestType::Community => { get_feed_community( - &mut *context.conn().await?, + context.conn().await?, &info.sort_type()?, &info.get_limit(), &info.get_page(), @@ -201,7 +201,7 @@ async fn get_feed( } RequestType::Front => { get_feed_front( - &mut *context.conn().await?, + context.conn().await?, &jwt_secret, &info.sort_type()?, &info.get_limit(), @@ -213,7 +213,7 @@ async fn get_feed( } RequestType::Inbox => { get_feed_inbox( - &mut *context.conn().await?, + context.conn().await?, &jwt_secret, ¶m, &protocol_and_hostname,