From 2bf8574bc8333d8d34ca542d61a0a5b50039c24d Mon Sep 17 00:00:00 2001 From: dull b Date: Tue, 4 Jul 2023 02:54:04 +0000 Subject: [PATCH] Fix some things --- crates/apub/src/lib.rs | 10 ++-- crates/apub/src/mentions.rs | 10 ++-- crates/apub/src/objects/comment.rs | 2 +- crates/apub/src/objects/community.rs | 2 +- crates/apub/src/objects/instance.rs | 2 +- crates/apub/src/objects/person.rs | 2 +- crates/apub/src/objects/post.rs | 2 +- crates/apub/src/objects/private_message.rs | 2 +- crates/apub/src/protocol/objects/group.rs | 2 +- crates/apub/src/protocol/objects/mod.rs | 8 +-- .../src/aggregates/comment_aggregates.rs | 4 +- .../src/aggregates/community_aggregates.rs | 2 +- .../src/aggregates/person_aggregates.rs | 2 +- .../src/aggregates/person_post_aggregates.rs | 4 +- .../src/aggregates/post_aggregates.rs | 4 +- .../src/aggregates/site_aggregates.rs | 2 +- crates/db_schema/src/impls/activity.rs | 10 ++-- crates/db_schema/src/impls/actor_language.rs | 56 +++++++++---------- crates/db_schema/src/impls/captcha_answer.rs | 8 +-- crates/db_schema/src/impls/comment.rs | 28 +++++----- crates/db_schema/src/impls/comment_reply.rs | 10 ++-- crates/db_schema/src/impls/comment_report.rs | 6 +- crates/db_schema/src/impls/community.rs | 6 +- crates/db_schema/src/impls/community_block.rs | 4 +- 24 files changed, 94 insertions(+), 94 deletions(-) diff --git a/crates/apub/src/lib.rs b/crates/apub/src/lib.rs index 33eeb552e..fa876e428 100644 --- a/crates/apub/src/lib.rs +++ b/crates/apub/src/lib.rs @@ -39,7 +39,7 @@ pub struct VerifyUrlData(pub DbPool); impl UrlVerifier for VerifyUrlData { async fn verify(&self, url: &Url) -> Result<(), &'static str> { let mut conn = get_conn(&self.0).await.expect("get connection"); - let local_site_data = fetch_local_site_data(&mut *conn) + let local_site_data = fetch_local_site_data(conn) .await .expect("read local site data"); check_apub_id_valid(url, &local_site_data)?; @@ -99,12 +99,12 @@ pub(crate) struct LocalSiteData { } pub(crate) async fn fetch_local_site_data( - mut conn: impl DbConn, + pool: &DbPool, ) -> Result { // LocalSite may be missing - let local_site = LocalSite::read(&mut *conn).await.ok(); - let allowed_instances = Instance::allowlist(&mut *conn).await?; - let blocked_instances = Instance::blocklist(&mut *conn).await?; + let local_site = LocalSite::read(get_conn(pool).await?).await.ok(); + let allowed_instances = Instance::allowlist(get_conn(pool).await?).await?; + let blocked_instances = Instance::blocklist(get_conn(pool).await?).await?; Ok(LocalSiteData { local_site, diff --git a/crates/apub/src/mentions.rs b/crates/apub/src/mentions.rs index dd3fa5bd3..558a184ea 100644 --- a/crates/apub/src/mentions.rs +++ b/crates/apub/src/mentions.rs @@ -9,7 +9,7 @@ use lemmy_api_common::context::LemmyContext; use lemmy_db_schema::{ source::{comment::Comment, person::Person, post::Post}, traits::Crud, - utils::DbConn, + utils::{DbConn, DbPool}, }; use lemmy_utils::{error::LemmyError, utils::mention::scrape_text_for_mentions}; use serde::{Deserialize, Serialize}; @@ -92,16 +92,16 @@ pub async fn collect_non_local_mentions( /// top-level comment, the creator of the post, otherwise the creator of the parent comment. #[tracing::instrument(skip(conn, comment))] async fn get_comment_parent_creator( - mut conn: impl DbConn, + pool: &DbPool, comment: &Comment, ) -> Result { let parent_creator_id = if let Some(parent_comment_id) = comment.parent_comment_id() { - let parent_comment = Comment::read(&mut *conn, parent_comment_id).await?; + let parent_comment = Comment::read(get_conn(pool).await?, parent_comment_id).await?; parent_comment.creator_id } else { let parent_post_id = comment.post_id; - let parent_post = Post::read(&mut *conn, parent_post_id).await?; + let parent_post = Post::read(get_conn(pool).await?, parent_post_id).await?; parent_post.creator_id }; - Ok(Person::read(&mut *conn, parent_creator_id).await?.into()) + Ok(Person::read(get_conn(pool).await?, parent_creator_id).await?.into()) } diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 2c00e6329..65354c345 100644 --- a/crates/apub/src/objects/comment.rs +++ b/crates/apub/src/objects/comment.rs @@ -132,7 +132,7 @@ impl Object for ApubComment { verify_domains_match(note.attributed_to.inner(), note.id.inner())?; verify_is_public(¬e.to, ¬e.cc)?; let community = note.community(context).await?; - let local_site_data = fetch_local_site_data(context.conn().await?).await?; + let local_site_data = fetch_local_site_data(context.pool()).await?; check_apub_id_valid_with_strictness( note.id.inner(), diff --git a/crates/apub/src/objects/community.rs b/crates/apub/src/objects/community.rs index 3f0fb31ff..408596814 100644 --- a/crates/apub/src/objects/community.rs +++ b/crates/apub/src/objects/community.rs @@ -188,7 +188,7 @@ impl ApubCommunity { ) -> Result, LemmyError> { let id = self.id; - let local_site_data = fetch_local_site_data(context.conn().await?).await?; + let local_site_data = fetch_local_site_data(context.pool()).await?; let follows = CommunityFollowerView::for_community(context.conn().await?, id).await?; let inboxes: Vec = follows .into_iter() diff --git a/crates/apub/src/objects/instance.rs b/crates/apub/src/objects/instance.rs index 8b395263f..7d6091aa1 100644 --- a/crates/apub/src/objects/instance.rs +++ b/crates/apub/src/objects/instance.rs @@ -197,7 +197,7 @@ pub(in crate::objects) async fn fetch_instance_actor_for_object + C pub(crate) async fn remote_instance_inboxes(mut conn: impl DbConn) -> Result, LemmyError> { Ok( - Site::read_remote_sites(&mut *conn) + Site::read_remote_sites(conn) .await? .into_iter() .map(|s| ApubSite::from(s).shared_inbox_or_inbox()) diff --git a/crates/apub/src/objects/person.rs b/crates/apub/src/objects/person.rs index 0462020e3..78d9b9acb 100644 --- a/crates/apub/src/objects/person.rs +++ b/crates/apub/src/objects/person.rs @@ -118,7 +118,7 @@ impl Object for ApubPerson { expected_domain: &Url, context: &Data, ) -> Result<(), LemmyError> { - let local_site_data = fetch_local_site_data(context.conn().await?).await?; + let local_site_data = fetch_local_site_data(context.pool()).await?; let slur_regex = &local_site_opt_to_slur_regex(&local_site_data.local_site); check_slurs(&person.preferred_username, slur_regex)?; diff --git a/crates/apub/src/objects/post.rs b/crates/apub/src/objects/post.rs index e0e405902..87786a8de 100644 --- a/crates/apub/src/objects/post.rs +++ b/crates/apub/src/objects/post.rs @@ -143,7 +143,7 @@ impl Object for ApubPost { verify_is_remote_object(page.id.inner(), context.settings())?; }; - let local_site_data = fetch_local_site_data(context.conn().await?).await?; + let local_site_data = fetch_local_site_data(context.pool()).await?; let community = page.community(context).await?; check_apub_id_valid_with_strictness( diff --git a/crates/apub/src/objects/private_message.rs b/crates/apub/src/objects/private_message.rs index 083cf01eb..c10d7b8c5 100644 --- a/crates/apub/src/objects/private_message.rs +++ b/crates/apub/src/objects/private_message.rs @@ -102,7 +102,7 @@ impl Object for ApubPrivateMessage { verify_domains_match(note.id.inner(), expected_domain)?; verify_domains_match(note.attributed_to.inner(), note.id.inner())?; - let local_site_data = fetch_local_site_data(context.conn().await?).await?; + let local_site_data = fetch_local_site_data(context.pool()).await?; check_apub_id_valid_with_strictness( note.id.inner(), diff --git a/crates/apub/src/protocol/objects/group.rs b/crates/apub/src/protocol/objects/group.rs index b3bd5d08c..2b32915af 100644 --- a/crates/apub/src/protocol/objects/group.rs +++ b/crates/apub/src/protocol/objects/group.rs @@ -80,7 +80,7 @@ impl Group { expected_domain: &Url, context: &LemmyContext, ) -> Result<(), LemmyError> { - let local_site_data = fetch_local_site_data(context.conn().await?).await?; + let local_site_data = fetch_local_site_data(context.pool()).await?; check_apub_id_valid_with_strictness( self.id.inner(), diff --git a/crates/apub/src/protocol/objects/mod.rs b/crates/apub/src/protocol/objects/mod.rs index c304a2b51..ade359502 100644 --- a/crates/apub/src/protocol/objects/mod.rs +++ b/crates/apub/src/protocol/objects/mod.rs @@ -35,7 +35,7 @@ impl LanguageTag { lang: LanguageId, mut conn: impl DbConn, ) -> Result, LemmyError> { - let lang = Language::read_from_id(&mut *conn, lang).await?; + let lang = Language::read_from_id(conn, lang).await?; // undetermined if lang.id == UNDETERMINED_ID { @@ -55,7 +55,7 @@ impl LanguageTag { let mut langs = Vec::::new(); for l in lang_ids { - langs.push(Language::read_from_id(&mut *conn, l).await?); + langs.push(Language::read_from_id(conn, l).await?); } let langs = langs @@ -73,7 +73,7 @@ impl LanguageTag { mut conn: impl DbConn, ) -> Result, LemmyError> { let identifier = lang.map(|l| l.identifier); - let language = Language::read_id_from_code(&mut *conn, identifier.as_deref()).await?; + let language = Language::read_id_from_code(conn, identifier.as_deref()).await?; Ok(language) } @@ -86,7 +86,7 @@ impl LanguageTag { for l in langs { let id = l.identifier; - language_ids.push(Language::read_id_from_code(&mut *conn, Some(&id)).await?); + language_ids.push(Language::read_id_from_code(conn, Some(&id)).await?); } Ok(language_ids.into_iter().flatten().collect()) diff --git a/crates/db_schema/src/aggregates/comment_aggregates.rs b/crates/db_schema/src/aggregates/comment_aggregates.rs index 8c913ff40..a5bcf8fb4 100644 --- a/crates/db_schema/src/aggregates/comment_aggregates.rs +++ b/crates/db_schema/src/aggregates/comment_aggregates.rs @@ -11,7 +11,7 @@ impl CommentAggregates { pub async fn read(mut conn: impl DbConn, comment_id: CommentId) -> Result { comment_aggregates::table .filter(comment_aggregates::comment_id.eq(comment_id)) - .first::(&mut *conn) + .first::(conn) .await } @@ -25,7 +25,7 @@ impl CommentAggregates { comment_aggregates::score, comment_aggregates::published, ))) - .get_result::(&mut *conn) + .get_result::(conn) .await } } diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index 61039b8ce..ac0de0d9a 100644 --- a/crates/db_schema/src/aggregates/community_aggregates.rs +++ b/crates/db_schema/src/aggregates/community_aggregates.rs @@ -11,7 +11,7 @@ impl CommunityAggregates { pub async fn read(mut conn: impl DbConn, community_id: CommunityId) -> Result { community_aggregates::table .filter(community_aggregates::community_id.eq(community_id)) - .first::(&mut *conn) + .first::(conn) .await } } diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index 6ec41b196..f72549012 100644 --- a/crates/db_schema/src/aggregates/person_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_aggregates.rs @@ -11,7 +11,7 @@ impl PersonAggregates { pub async fn read(mut conn: impl DbConn, person_id: PersonId) -> Result { person_aggregates::table .filter(person_aggregates::person_id.eq(person_id)) - .first::(&mut *conn) + .first::(conn) .await } } diff --git a/crates/db_schema/src/aggregates/person_post_aggregates.rs b/crates/db_schema/src/aggregates/person_post_aggregates.rs index ecf2e39fc..fd2ee9926 100644 --- a/crates/db_schema/src/aggregates/person_post_aggregates.rs +++ b/crates/db_schema/src/aggregates/person_post_aggregates.rs @@ -18,7 +18,7 @@ impl PersonPostAggregates { .on_conflict((person_id, post_id)) .do_update() .set(form) - .get_result::(&mut *conn) + .get_result::(conn) .await } pub async fn read( @@ -28,7 +28,7 @@ impl PersonPostAggregates { ) -> Result { person_post_aggregates .filter(post_id.eq(post_id_).and(person_id.eq(person_id_))) - .first::(&mut *conn) + .first::(conn) .await } } diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index fe9652e10..e84e4e224 100644 --- a/crates/db_schema/src/aggregates/post_aggregates.rs +++ b/crates/db_schema/src/aggregates/post_aggregates.rs @@ -11,7 +11,7 @@ impl PostAggregates { pub async fn read(mut conn: impl DbConn, post_id: PostId) -> Result { post_aggregates::table .filter(post_aggregates::post_id.eq(post_id)) - .first::(&mut *conn) + .first::(conn) .await } @@ -25,7 +25,7 @@ impl PostAggregates { post_aggregates::newest_comment_time_necro, )), )) - .get_result::(&mut *conn) + .get_result::(conn) .await } } diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index a1bcf5bdd..e752c4ff6 100644 --- a/crates/db_schema/src/aggregates/site_aggregates.rs +++ b/crates/db_schema/src/aggregates/site_aggregates.rs @@ -4,7 +4,7 @@ use diesel_async::RunQueryDsl; impl SiteAggregates { pub async fn read(mut conn: impl DbConn) -> Result { - site_aggregates::table.first::(&mut *conn).await + site_aggregates::table.first::(conn).await } } diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index 672d831ff..b271ee9be 100644 --- a/crates/db_schema/src/impls/activity.rs +++ b/crates/db_schema/src/impls/activity.rs @@ -14,13 +14,13 @@ impl Crud for Activity { type UpdateForm = ActivityUpdateForm; type IdType = i32; async fn read(mut conn: impl DbConn, activity_id: i32) -> Result { - activity.find(activity_id).first::(&mut *conn).await + activity.find(activity_id).first::(conn).await } async fn create(mut conn: impl DbConn, new_activity: &Self::InsertForm) -> Result { insert_into(activity) .values(new_activity) - .get_result::(&mut *conn) + .get_result::(conn) .await } @@ -31,12 +31,12 @@ impl Crud for Activity { ) -> Result { diesel::update(activity.find(activity_id)) .set(new_activity) - .get_result::(&mut *conn) + .get_result::(conn) .await } async fn delete(mut conn: impl DbConn, activity_id: i32) -> Result { diesel::delete(activity.find(activity_id)) - .execute(&mut *conn) + .execute(conn) .await } } @@ -48,7 +48,7 @@ impl Activity { ) -> Result { activity .filter(ap_id.eq(object_id)) - .first::(&mut *conn) + .first::(conn) .await } } diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index cc4cc5389..160733251 100644 --- a/crates/db_schema/src/impls/actor_language.rs +++ b/crates/db_schema/src/impls/actor_language.rs @@ -62,14 +62,14 @@ impl LocalUserLanguage { /// /// If no language_id vector is given, it will show all languages pub async fn update( - mut conn: impl DbConn, + pool: &DbPool, language_ids: Vec, for_local_user_id: LocalUserId, ) -> Result<(), Error> { - let mut lang_ids = convert_update_languages(&mut *conn, language_ids).await?; + let mut lang_ids = convert_update_languages(get_conn(pool).await?, language_ids).await?; // No need to update if languages are unchanged - let current = LocalUserLanguage::read(&mut *conn, for_local_user_id).await?; + let current = LocalUserLanguage::read(get_conn(pool).await?, for_local_user_id).await?; if current == lang_ids { return Ok(()); } @@ -84,7 +84,7 @@ impl LocalUserLanguage { lang_ids.push(UNDETERMINED_ID); } - conn + get_conn(pool).await? .build_transaction() .run(|conn| { Box::pin(async move { @@ -118,7 +118,7 @@ impl SiteLanguage { .inner_join(site_language::table) .order(site_language::id) .select(site_language::language_id) - .load(&mut *conn) + .load(conn) .await } @@ -127,32 +127,32 @@ impl SiteLanguage { .filter(site_language::site_id.eq(for_site_id)) .order(site_language::language_id) .select(site_language::language_id) - .load(&mut *conn) + .load(conn) .await } - pub async fn read(mut conn: impl DbConn, for_site_id: SiteId) -> Result, Error> { - let langs = Self::read_raw(&mut *conn, for_site_id).await?; + pub async fn read(pool: &DbPool, for_site_id: SiteId) -> Result, Error> { + let langs = Self::read_raw(get_conn(pool).await?, for_site_id).await?; - convert_read_languages(&mut *conn, langs).await + convert_read_languages(get_conn(pool).await?, langs).await } pub async fn update( - mut conn: impl DbConn, + pool: &DbPool, language_ids: Vec, site: &Site, ) -> Result<(), Error> { let for_site_id = site.id; let instance_id = site.instance_id; - let lang_ids = convert_update_languages(&mut *conn, language_ids).await?; + let lang_ids = convert_update_languages(get_conn(pool).await?, language_ids).await?; // No need to update if languages are unchanged - let current = SiteLanguage::read(&mut *conn, site.id).await?; + let current = SiteLanguage::read(get_conn(pool).await?, site.id).await?; if current == lang_ids { return Ok(()); } - conn + get_conn(pool).await? .build_transaction() .run(|conn| { Box::pin(async move { @@ -198,7 +198,7 @@ impl CommunityLanguage { .filter(language_id.eq(for_language_id)) .filter(community_id.eq(for_community_id)), )) - .get_result(&mut *conn) + .get_result(conn) .await?; if is_allowed { @@ -216,7 +216,7 @@ impl CommunityLanguage { /// community language, and it shouldnt be possible to post content in languages which are not /// allowed by local site. async fn limit_languages( - mut conn: impl DbConn, + pool: &DbPool, for_instance_id: InstanceId, ) -> Result<(), Error> { use crate::schema::{ @@ -230,12 +230,12 @@ impl CommunityLanguage { .filter(c::instance_id.eq(for_instance_id)) .filter(sl::language_id.is_null()) .select(cl::language_id) - .get_results(&mut *conn) + .get_results(get_conn(pool).await?) .await?; for c in community_languages { delete(cl::community_language.filter(cl::language_id.eq(c))) - .execute(&mut *conn) + .execute(get_conn(pool).await?) .await?; } Ok(()) @@ -250,35 +250,35 @@ impl CommunityLanguage { .filter(community_id.eq(for_community_id)) .order(language_id) .select(language_id) - .get_results(&mut *conn) + .get_results(conn) .await } pub async fn read( - mut conn: impl DbConn, + pool: &DbPool for_community_id: CommunityId, ) -> Result, Error> { - let langs = Self::read_raw(&mut *conn, for_community_id).await?; - convert_read_languages(&mut *conn, langs).await + let langs = Self::read_raw(get_conn(pool).await?, for_community_id).await?; + convert_read_languages(get_conn(pool).await?, langs).await } pub async fn update( - mut conn: impl DbConn, + pool: &DbPool, mut language_ids: Vec, for_community_id: CommunityId, ) -> Result<(), Error> { if language_ids.is_empty() { - language_ids = SiteLanguage::read_local_raw(&mut *conn).await?; + language_ids = SiteLanguage::read_local_raw(get_conn(pool).await?).await?; } - let lang_ids = convert_update_languages(&mut *conn, language_ids).await?; + let lang_ids = convert_update_languages(get_conn(pool).await?, language_ids).await?; // No need to update if languages are unchanged - let current = CommunityLanguage::read_raw(&mut *conn, for_community_id).await?; + let current = CommunityLanguage::read_raw(get_conn(pool).await?, for_community_id).await?; if current == lang_ids { return Ok(()); } - conn + get_conn(pool).await? .build_transaction() .run(|conn| { Box::pin(async move { @@ -316,7 +316,7 @@ pub async fn default_post_language( .filter(ul::local_user_id.eq(local_user_id)) .filter(cl::community_id.eq(community_id)) .select(cl::language_id) - .get_results::(&mut *conn) + .get_results::(conn) .await?; if intersection.len() == 1 { @@ -358,7 +358,7 @@ async fn convert_read_languages( use crate::schema::language::dsl::{id, language}; let count: i64 = language .select(count(id)) - .first(&mut *conn) + .first(conn) .await .expect("read number of languages"); count as usize diff --git a/crates/db_schema/src/impls/captcha_answer.rs b/crates/db_schema/src/impls/captcha_answer.rs index 3605c24f4..59f049e92 100644 --- a/crates/db_schema/src/impls/captcha_answer.rs +++ b/crates/db_schema/src/impls/captcha_answer.rs @@ -18,12 +18,12 @@ impl CaptchaAnswer { pub async fn insert(mut conn: impl DbConn, captcha: &CaptchaAnswerForm) -> Result { insert_into(captcha_answer) .values(captcha) - .get_result::(&mut *conn) + .get_result::(conn) .await } pub async fn check_captcha( - mut conn: impl DbConn, + pool: &DbPool, to_check: CheckCaptchaAnswer, ) -> Result { // fetch requested captcha @@ -32,12 +32,12 @@ impl CaptchaAnswer { .filter((uuid).eq(to_check.uuid)) .filter(lower(answer).eq(to_check.answer.to_lowercase().clone())), )) - .get_result::(&mut *conn) + .get_result::(get_conn(pool).await?) .await?; // delete checked captcha delete(captcha_answer.filter(uuid.eq(to_check.uuid))) - .execute(&mut *conn) + .execute(get_conn(pool).await?) .await?; Ok(captcha_exists) diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 4f9902531..4a5a92dd3 100644 --- a/crates/db_schema/src/impls/comment.rs +++ b/crates/db_schema/src/impls/comment.rs @@ -34,7 +34,7 @@ impl Comment { deleted.eq(true), updated.eq(naive_now()), )) - .get_results::(&mut *conn) + .get_results::(conn) .await } @@ -45,12 +45,12 @@ impl Comment { ) -> Result, Error> { diesel::update(comment.filter(creator_id.eq(for_creator_id))) .set((removed.eq(new_removed), updated.eq(naive_now()))) - .get_results::(&mut *conn) + .get_results::(conn) .await } pub async fn create( - mut conn: impl DbConn, + pool: &DbPool, comment_form: &CommentInsertForm, parent_path: Option<&Ltree>, ) -> Result { @@ -60,7 +60,7 @@ impl Comment { .on_conflict(ap_id) .do_update() .set(comment_form) - .get_result::(&mut *conn) + .get_result::(get_conn(pool).await?) .await; if let Ok(comment_insert) = inserted_comment { @@ -78,7 +78,7 @@ impl Comment { let updated_comment = diesel::update(comment.find(comment_id)) .set(path.eq(ltree)) - .get_result::(&mut *conn) + .get_result::(get_conn(pool).await?) .await; // Update the child count for the parent comment_aggregates @@ -111,7 +111,7 @@ where ca.comment_id = c.id" ); sql_query(update_child_count_stmt) - .execute(&mut *conn) + .execute(get_conn(pool).await?) .await?; } } @@ -128,7 +128,7 @@ where ca.comment_id = c.id" Ok( comment .filter(ap_id.eq(object_id)) - .first::(&mut *conn) + .first::(conn) .await .ok() .map(Into::into), @@ -153,12 +153,12 @@ impl Crud for Comment { type UpdateForm = CommentUpdateForm; type IdType = CommentId; async fn read(mut conn: impl DbConn, comment_id: CommentId) -> Result { - comment.find(comment_id).first::(&mut *conn).await + comment.find(comment_id).first::(conn).await } async fn delete(mut conn: impl DbConn, comment_id: CommentId) -> Result { diesel::delete(comment.find(comment_id)) - .execute(&mut *conn) + .execute(conn) .await } @@ -174,7 +174,7 @@ impl Crud for Comment { ) -> Result { diesel::update(comment.find(comment_id)) .set(comment_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } } @@ -190,7 +190,7 @@ impl Likeable for CommentLike { .on_conflict((comment_id, person_id)) .do_update() .set(comment_like_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } async fn remove( @@ -204,7 +204,7 @@ impl Likeable for CommentLike { .filter(comment_id.eq(comment_id_)) .filter(person_id.eq(person_id_)), ) - .execute(&mut *conn) + .execute(conn) .await } } @@ -222,7 +222,7 @@ impl Saveable for CommentSaved { .on_conflict((comment_id, person_id)) .do_update() .set(comment_saved_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } async fn unsave( @@ -235,7 +235,7 @@ impl Saveable for CommentSaved { .filter(comment_id.eq(comment_saved_form.comment_id)) .filter(person_id.eq(comment_saved_form.person_id)), ) - .execute(&mut *conn) + .execute(conn) .await } } diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index 4569082f3..8396e96ad 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 read(mut conn: impl DbConn, comment_reply_id: CommentReplyId) -> Result { comment_reply .find(comment_reply_id) - .first::(&mut *conn) + .first::(conn) .await } @@ -31,7 +31,7 @@ impl Crud for CommentReply { .on_conflict((recipient_id, comment_id)) .do_update() .set(comment_reply_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } @@ -42,7 +42,7 @@ impl Crud for CommentReply { ) -> Result { diesel::update(comment_reply.find(comment_reply_id)) .set(comment_reply_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } } @@ -58,7 +58,7 @@ impl CommentReply { .filter(read.eq(false)), ) .set(read.eq(true)) - .get_results::(&mut *conn) + .get_results::(conn) .await } @@ -68,7 +68,7 @@ impl CommentReply { ) -> Result { comment_reply .filter(comment_id.eq(for_comment_id)) - .first::(&mut *conn) + .first::(conn) .await } } diff --git a/crates/db_schema/src/impls/comment_report.rs b/crates/db_schema/src/impls/comment_report.rs index e78bae0d6..94a6af937 100644 --- a/crates/db_schema/src/impls/comment_report.rs +++ b/crates/db_schema/src/impls/comment_report.rs @@ -27,7 +27,7 @@ impl Reportable for CommentReport { ) -> Result { insert_into(comment_report) .values(comment_report_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } @@ -47,7 +47,7 @@ impl Reportable for CommentReport { resolver_id.eq(by_resolver_id), updated.eq(naive_now()), )) - .execute(&mut *conn) + .execute(conn) .await } @@ -67,7 +67,7 @@ impl Reportable for CommentReport { resolver_id.eq(by_resolver_id), updated.eq(naive_now()), )) - .execute(&mut *conn) + .execute(conn) .await } } diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 6b0cb196c..3d8d52d37 100644 --- a/crates/db_schema/src/impls/community.rs +++ b/crates/db_schema/src/impls/community.rs @@ -30,19 +30,19 @@ impl Crud for Community { async fn read(mut conn: impl DbConn, community_id: CommunityId) -> Result { community::table .find(community_id) - .first::(&mut *conn) + .first::(conn) .await } async fn delete(mut conn: impl DbConn, community_id: CommunityId) -> Result { diesel::delete(community::table.find(community_id)) - .execute(&mut *conn) + .execute(conn) .await } async fn create(mut conn: impl DbConn, form: &Self::InsertForm) -> Result { let is_new_community = match &form.actor_id { - Some(id) => Community::read_from_apub_id(&mut *conn, id) + Some(id) => Community::read_from_apub_id(conn, id) .await? .is_none(), None => true, diff --git a/crates/db_schema/src/impls/community_block.rs b/crates/db_schema/src/impls/community_block.rs index 041440244..c88ba2a91 100644 --- a/crates/db_schema/src/impls/community_block.rs +++ b/crates/db_schema/src/impls/community_block.rs @@ -16,7 +16,7 @@ impl Blockable for CommunityBlock { .on_conflict((person_id, community_id)) .do_update() .set(community_block_form) - .get_result::(&mut *conn) + .get_result::(conn) .await } async fn unblock( @@ -28,7 +28,7 @@ impl Blockable for CommunityBlock { .filter(person_id.eq(community_block_form.person_id)) .filter(community_id.eq(community_block_form.community_id)), ) - .execute(&mut *conn) + .execute(conn) .await } }