From 0957e2b319b8fbb8eaced6345150dc2904d10050 Mon Sep 17 00:00:00 2001 From: dull b Date: Sat, 1 Jul 2023 04:11:27 +0000 Subject: [PATCH] Fix stuff --- crates/api/src/comment_report/list.rs | 3 +-- .../local_user/notifications/list_mentions.rs | 3 +-- .../local_user/notifications/list_replies.rs | 3 +-- crates/api/src/post_report/list.rs | 3 +-- crates/api/src/private_message_report/list.rs | 3 +-- .../site/registration_applications/list.rs | 3 +-- crates/api_crud/src/community/list.rs | 3 +-- crates/apub/src/api/list_comments.rs | 3 +-- crates/apub/src/api/list_posts.rs | 3 +-- crates/apub/src/api/read_person.rs | 6 ++---- crates/apub/src/api/search.rs | 19 +++++++++---------- .../src/collections/community_featured.rs | 2 +- .../src/collections/community_moderators.rs | 9 ++++----- .../apub/src/collections/community_outbox.rs | 4 ++-- crates/apub/src/lib.rs | 2 +- crates/apub/src/objects/community.rs | 4 ++-- crates/apub/src/objects/instance.rs | 17 ++++++++--------- crates/routes/src/feeds.rs | 3 +-- 18 files changed, 39 insertions(+), 54 deletions(-) diff --git a/crates/api/src/comment_report/list.rs b/crates/api/src/comment_report/list.rs index 99e3fb66c..149e9b363 100644 --- a/crates/api/src/comment_report/list.rs +++ b/crates/api/src/comment_report/list.rs @@ -29,9 +29,8 @@ impl Perform for ListCommentReports { let page = data.page; let limit = data.limit; - let mut conn = context.conn().await?; let comment_reports = CommentReportQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .my_person_id(person_id) .admin(admin) .community_id(community_id) diff --git a/crates/api/src/local_user/notifications/list_mentions.rs b/crates/api/src/local_user/notifications/list_mentions.rs index b35699b56..d7d1c516f 100644 --- a/crates/api/src/local_user/notifications/list_mentions.rs +++ b/crates/api/src/local_user/notifications/list_mentions.rs @@ -27,9 +27,8 @@ impl Perform for GetPersonMentions { let person_id = Some(local_user_view.person.id); let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts); - let mut conn = context.conn().await?; let mentions = PersonMentionQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .recipient_id(person_id) .my_person_id(person_id) .sort(sort) diff --git a/crates/api/src/local_user/notifications/list_replies.rs b/crates/api/src/local_user/notifications/list_replies.rs index b41341764..6e7e2034d 100644 --- a/crates/api/src/local_user/notifications/list_replies.rs +++ b/crates/api/src/local_user/notifications/list_replies.rs @@ -24,9 +24,8 @@ impl Perform for GetReplies { let person_id = Some(local_user_view.person.id); let show_bot_accounts = Some(local_user_view.local_user.show_bot_accounts); - let mut conn = context.conn().await?; let replies = CommentReplyQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .recipient_id(person_id) .my_person_id(person_id) .sort(sort) diff --git a/crates/api/src/post_report/list.rs b/crates/api/src/post_report/list.rs index 646163347..69d5fbdff 100644 --- a/crates/api/src/post_report/list.rs +++ b/crates/api/src/post_report/list.rs @@ -29,9 +29,8 @@ impl Perform for ListPostReports { let page = data.page; let limit = data.limit; - let mut conn = context.conn().await?; let post_reports = PostReportQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .my_person_id(person_id) .admin(admin) .community_id(community_id) diff --git a/crates/api/src/private_message_report/list.rs b/crates/api/src/private_message_report/list.rs index 2e3e380d4..8137cf2d5 100644 --- a/crates/api/src/private_message_report/list.rs +++ b/crates/api/src/private_message_report/list.rs @@ -21,9 +21,8 @@ impl Perform for ListPrivateMessageReports { let unresolved_only = self.unresolved_only; let page = self.page; let limit = self.limit; - let mut conn = context.conn().await?; let private_message_reports = PrivateMessageReportQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .unresolved_only(unresolved_only) .page(page) .limit(limit) diff --git a/crates/api/src/site/registration_applications/list.rs b/crates/api/src/site/registration_applications/list.rs index 658095eb4..80ceea1b5 100644 --- a/crates/api/src/site/registration_applications/list.rs +++ b/crates/api/src/site/registration_applications/list.rs @@ -27,9 +27,8 @@ impl Perform for ListRegistrationApplications { let page = data.page; let limit = data.limit; - let mut conn = context.conn().await?; let registration_applications = RegistrationApplicationQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .unread_only(unread_only) .verified_email_only(Some(verified_email_only)) .page(page) diff --git a/crates/api_crud/src/community/list.rs b/crates/api_crud/src/community/list.rs index 5f11e5878..10544d7f8 100644 --- a/crates/api_crud/src/community/list.rs +++ b/crates/api_crud/src/community/list.rs @@ -31,9 +31,8 @@ impl PerformCrud for ListCommunities { let page = data.page; let limit = data.limit; let local_user = local_user_view.map(|l| l.local_user); - let mut conn = context.conn().await?; let communities = CommunityQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .listing_type(listing_type) .show_nsfw(show_nsfw) .sort(sort) diff --git a/crates/apub/src/api/list_comments.rs b/crates/apub/src/api/list_comments.rs index 101dfea80..3eb9d2fff 100644 --- a/crates/apub/src/api/list_comments.rs +++ b/crates/apub/src/api/list_comments.rs @@ -54,9 +54,8 @@ impl PerformApub for GetComments { let parent_path_cloned = parent_path.clone(); let post_id = data.post_id; let local_user = local_user_view.map(|l| l.local_user); - let mut conn = context.conn().await?; let comments = CommentQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .listing_type(Some(listing_type)) .sort(sort) .max_depth(max_depth) diff --git a/crates/apub/src/api/list_posts.rs b/crates/apub/src/api/list_posts.rs index 58520c870..179bd92fb 100644 --- a/crates/apub/src/api/list_posts.rs +++ b/crates/apub/src/api/list_posts.rs @@ -49,9 +49,8 @@ impl PerformApub for GetPosts { .await .is_ok(); - let mut conn = context.conn().await?; let posts = PostQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .local_user(local_user_view.map(|l| l.local_user).as_ref()) .listing_type(Some(listing_type)) .sort(sort) diff --git a/crates/apub/src/api/read_person.rs b/crates/apub/src/api/read_person.rs index ac4097735..5ebb905b7 100644 --- a/crates/apub/src/api/read_person.rs +++ b/crates/apub/src/api/read_person.rs @@ -63,9 +63,8 @@ impl PerformApub for GetPersonDetails { let local_user = local_user_view.map(|l| l.local_user); let local_user_clone = local_user.clone(); - let mut conn = context.conn().await?; let posts_query = PostQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .saved_only(saved_only) .local_user(local_user.as_ref()) @@ -86,9 +85,8 @@ impl PerformApub for GetPersonDetails { } .await?; - let mut conn = context.conn().await?; let comments_query = CommentQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .local_user(local_user_clone.as_ref()) .sort(sort.map(post_to_comment_sort_type)) .saved_only(saved_only) diff --git a/crates/apub/src/api/search.rs b/crates/apub/src/api/search.rs index 5b58203a6..86137decd 100644 --- a/crates/apub/src/api/search.rs +++ b/crates/apub/src/api/search.rs @@ -56,11 +56,10 @@ impl PerformApub for Search { }; let creator_id = data.creator_id; let local_user = local_user_view.map(|l| l.local_user); - let mut conn = context.conn().await?; match search_type { SearchType::Posts => { posts = PostQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .listing_type(listing_type) .community_id(community_id) @@ -76,7 +75,7 @@ impl PerformApub for Search { } SearchType::Comments => { comments = CommentQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort.map(post_to_comment_sort_type)) .listing_type(listing_type) .search_term(Some(q)) @@ -91,7 +90,7 @@ impl PerformApub for Search { } SearchType::Communities => { communities = CommunityQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .listing_type(listing_type) .search_term(Some(q)) @@ -105,7 +104,7 @@ impl PerformApub for Search { } SearchType::Users => { users = PersonQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .search_term(Some(q)) .page(page) @@ -121,7 +120,7 @@ impl PerformApub for Search { let local_user_ = local_user.clone(); posts = PostQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .listing_type(listing_type) .community_id(community_id) @@ -139,7 +138,7 @@ impl PerformApub for Search { let local_user_ = local_user.clone(); comments = CommentQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort.map(post_to_comment_sort_type)) .listing_type(listing_type) .search_term(Some(q)) @@ -158,7 +157,7 @@ impl PerformApub for Search { vec![] } else { CommunityQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .listing_type(listing_type) .search_term(Some(q)) @@ -177,7 +176,7 @@ impl PerformApub for Search { vec![] } else { PersonQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .search_term(Some(q)) .page(page) @@ -189,7 +188,7 @@ impl PerformApub for Search { } SearchType::Url => { posts = PostQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .sort(sort) .listing_type(listing_type) .community_id(community_id) diff --git a/crates/apub/src/collections/community_featured.rs b/crates/apub/src/collections/community_featured.rs index 66673eeea..730e086fd 100644 --- a/crates/apub/src/collections/community_featured.rs +++ b/crates/apub/src/collections/community_featured.rs @@ -29,7 +29,7 @@ impl Collection for ApubCommunityFeatured { data: &Data, ) -> Result { let ordered_items = try_join_all( - Post::list_featured_for_community(&mut *data.conn().await?, owner.id) + Post::list_featured_for_community(data.conn().await?, owner.id) .await? .into_iter() .map(ApubPost::from) diff --git a/crates/apub/src/collections/community_moderators.rs b/crates/apub/src/collections/community_moderators.rs index cd57a63ac..8b8946bff 100644 --- a/crates/apub/src/collections/community_moderators.rs +++ b/crates/apub/src/collections/community_moderators.rs @@ -33,8 +33,7 @@ impl Collection for ApubCommunityModerators { owner: &Self::Owner, data: &Data, ) -> Result { - let moderators = - CommunityModeratorView::for_community(&mut *data.conn().await?, owner.id).await?; + let moderators = CommunityModeratorView::for_community(data.conn().await?, owner.id).await?; let ordered_items = moderators .into_iter() .map(|m| ObjectId::::from(m.moderator.actor_id)) @@ -64,7 +63,7 @@ impl Collection for ApubCommunityModerators { ) -> Result { let community_id = owner.id; let current_moderators = - CommunityModeratorView::for_community(&mut *data.conn().await?, community_id).await?; + CommunityModeratorView::for_community(data.conn().await?, community_id).await?; // Remove old mods from database which arent in the moderators collection anymore for mod_user in ¤t_moderators { let mod_id = ObjectId::from(mod_user.moderator.actor_id.clone()); @@ -73,7 +72,7 @@ impl Collection for ApubCommunityModerators { community_id: mod_user.community.id, person_id: mod_user.moderator.id, }; - CommunityModerator::leave(&mut *data.conn().await?, &community_moderator_form).await?; + CommunityModerator::leave(data.conn().await?, &community_moderator_form).await?; } } @@ -90,7 +89,7 @@ impl Collection for ApubCommunityModerators { community_id: owner.id, person_id: mod_user.id, }; - CommunityModerator::join(&mut *data.conn().await?, &community_moderator_form).await?; + CommunityModerator::join(data.conn().await?, &community_moderator_form).await?; } } diff --git a/crates/apub/src/collections/community_outbox.rs b/crates/apub/src/collections/community_outbox.rs index 8ef0ce0be..550d7dbee 100644 --- a/crates/apub/src/collections/community_outbox.rs +++ b/crates/apub/src/collections/community_outbox.rs @@ -41,14 +41,14 @@ impl Collection for ApubCommunityOutbox { owner: &Self::Owner, data: &Data, ) -> Result { - let post_list: Vec = Post::list_for_community(&mut *data.conn().await?, owner.id) + let post_list: Vec = Post::list_for_community(data.conn().await?, owner.id) .await? .into_iter() .map(Into::into) .collect(); let mut ordered_items = vec![]; for post in post_list { - let person = Person::read(&mut *data.conn().await?, post.creator_id) + let person = Person::read(data.conn().await?, post.creator_id) .await? .into(); let create = diff --git a/crates/apub/src/lib.rs b/crates/apub/src/lib.rs index 319d1d45b..33eeb552e 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -176,7 +176,7 @@ where sensitive: Some(sensitive), updated: None, }; - Activity::create(&mut *data.conn().await?, &form).await?; + Activity::create(data.conn().await?, &form).await?; Ok(()) } diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 64043f225..3f0fb31ff 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -83,8 +83,8 @@ impl Object for ApubCommunity { #[tracing::instrument(skip_all)] async fn into_json(self, data: &Data) -> Result { let community_id = self.id; - let langs = CommunityLanguage::read(&mut *data.conn().await?, community_id).await?; - let language = LanguageTag::new_multiple(langs, &mut *data.conn().await?).await?; + let langs = CommunityLanguage::read(data.conn().await?, community_id).await?; + let language = LanguageTag::new_multiple(langs, data.conn().await?).await?; let group = Group { kind: GroupType::Group, diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 9afbe85b7..8b395263f 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -71,7 +71,7 @@ impl Object for ApubSite { data: &Data, ) -> Result, LemmyError> { Ok( - Site::read_from_apub_id(&mut *data.conn().await?, &object_id.into()) + Site::read_from_apub_id(data.conn().await?, &object_id.into()) .await? .map(Into::into), ) @@ -84,8 +84,8 @@ impl Object for ApubSite { #[tracing::instrument(skip_all)] async fn into_json(self, data: &Data) -> Result { let site_id = self.id; - let langs = SiteLanguage::read(&mut *data.conn().await?, site_id).await?; - let language = LanguageTag::new_multiple(langs, &mut *data.conn().await?).await?; + let langs = SiteLanguage::read(data.conn().await?, site_id).await?; + let language = LanguageTag::new_multiple(langs, data.conn().await?).await?; let instance = Instance { kind: ApplicationType::Application, @@ -113,7 +113,7 @@ impl Object for ApubSite { expected_domain: &Url, data: &Data, ) -> Result<(), LemmyError> { - let local_site_data = fetch_local_site_data(&mut *data.conn().await?).await?; + let local_site_data = fetch_local_site_data(data.conn().await?).await?; check_apub_id_valid_with_strictness(apub.id.inner(), true, &local_site_data, data.settings())?; verify_domains_match(expected_domain, apub.id.inner())?; @@ -128,7 +128,7 @@ impl Object for ApubSite { #[tracing::instrument(skip_all)] async fn from_json(apub: Self::Kind, data: &Data) -> Result { let domain = apub.id.inner().domain().expect("group id has domain"); - let instance = DbInstance::read_or_create(&mut *data.conn().await?, domain.to_string()).await?; + let instance = DbInstance::read_or_create(data.conn().await?, domain.to_string()).await?; let site_form = SiteInsertForm { name: apub.name.clone(), @@ -144,11 +144,10 @@ impl Object for ApubSite { private_key: None, instance_id: instance.id, }; - let languages = - LanguageTag::to_language_id_multiple(apub.language, &mut *data.conn().await?).await?; + let languages = LanguageTag::to_language_id_multiple(apub.language, data.conn().await?).await?; - let site = Site::create(&mut *data.conn().await?, &site_form).await?; - SiteLanguage::update(&mut *data.conn().await?, languages, &site).await?; + let site = Site::create(data.conn().await?, &site_form).await?; + SiteLanguage::update(data.conn().await?, languages, &site).await?; Ok(site.into()) } } diff --git a/crates/routes/src/feeds.rs b/crates/routes/src/feeds.rs index 229c24ab9..29b893736 100644 --- a/crates/routes/src/feeds.rs +++ b/crates/routes/src/feeds.rs @@ -124,9 +124,8 @@ async fn get_feed_data( ) -> Result { let site_view = SiteView::read_local(context.conn().await?).await?; - let mut conn = context.conn().await?; let posts = PostQuery::builder() - .conn(&mut *conn) + .conn(context.conn().await?) .listing_type(Some(listing_type)) .sort(Some(sort_type)) .limit(Some(limit))