From 0a8d1f8cafed72a4830aff1250cceab7929b82a6 Mon Sep 17 00:00:00 2001 From: dull b Date: Tue, 4 Jul 2023 02:54:33 +0000 Subject: [PATCH] Revert "Fix some things" This reverts commit 2bf8574bc8333d8d34ca542d61a0a5b50039c24d. --- 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 fa876e428..33eeb552e 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(conn) + let local_site_data = fetch_local_site_data(&mut *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( - pool: &DbPool, + mut conn: impl DbConn, ) -> Result { // LocalSite may be missing - 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?; + 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?; Ok(LocalSiteData { local_site, diff --git a/crates/apub/src/mentions.rs b/crates/apub/src/mentions.rs index 558a184ea..dd3fa5bd3 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, DbPool}, + utils::DbConn, }; 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( - pool: &DbPool, + mut conn: impl DbConn, comment: &Comment, ) -> Result { let parent_creator_id = if let Some(parent_comment_id) = comment.parent_comment_id() { - let parent_comment = Comment::read(get_conn(pool).await?, parent_comment_id).await?; + let parent_comment = Comment::read(&mut *conn, parent_comment_id).await?; parent_comment.creator_id } else { let parent_post_id = comment.post_id; - let parent_post = Post::read(get_conn(pool).await?, parent_post_id).await?; + let parent_post = Post::read(&mut *conn, parent_post_id).await?; parent_post.creator_id }; - Ok(Person::read(get_conn(pool).await?, parent_creator_id).await?.into()) + Ok(Person::read(&mut *conn, parent_creator_id).await?.into()) } diff --git a/crates/apub/src/objects/comment.rs b/crates/apub/src/objects/comment.rs index 65354c345..2c00e6329 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.pool()).await?; + let local_site_data = fetch_local_site_data(context.conn().await?).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 408596814..3f0fb31ff 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.pool()).await?; + let local_site_data = fetch_local_site_data(context.conn().await?).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 7d6091aa1..8b395263f 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(conn) + Site::read_remote_sites(&mut *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 78d9b9acb..0462020e3 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.pool()).await?; + let local_site_data = fetch_local_site_data(context.conn().await?).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 87786a8de..e0e405902 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.pool()).await?; + let local_site_data = fetch_local_site_data(context.conn().await?).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 c10d7b8c5..083cf01eb 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.pool()).await?; + let local_site_data = fetch_local_site_data(context.conn().await?).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 2b32915af..b3bd5d08c 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.pool()).await?; + let local_site_data = fetch_local_site_data(context.conn().await?).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 ade359502..c304a2b51 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(conn, lang).await?; + let lang = Language::read_from_id(&mut *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(conn, l).await?); + langs.push(Language::read_from_id(&mut *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(conn, identifier.as_deref()).await?; + let language = Language::read_id_from_code(&mut *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(conn, Some(&id)).await?); + language_ids.push(Language::read_id_from_code(&mut *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 a5bcf8fb4..8c913ff40 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::(conn) + .first::(&mut *conn) .await } @@ -25,7 +25,7 @@ impl CommentAggregates { comment_aggregates::score, comment_aggregates::published, ))) - .get_result::(conn) + .get_result::(&mut *conn) .await } } diff --git a/crates/db_schema/src/aggregates/community_aggregates.rs b/crates/db_schema/src/aggregates/community_aggregates.rs index ac0de0d9a..61039b8ce 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::(conn) + .first::(&mut *conn) .await } } diff --git a/crates/db_schema/src/aggregates/person_aggregates.rs b/crates/db_schema/src/aggregates/person_aggregates.rs index f72549012..6ec41b196 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::(conn) + .first::(&mut *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 fd2ee9926..ecf2e39fc 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::(conn) + .get_result::(&mut *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::(conn) + .first::(&mut *conn) .await } } diff --git a/crates/db_schema/src/aggregates/post_aggregates.rs b/crates/db_schema/src/aggregates/post_aggregates.rs index e84e4e224..fe9652e10 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::(conn) + .first::(&mut *conn) .await } @@ -25,7 +25,7 @@ impl PostAggregates { post_aggregates::newest_comment_time_necro, )), )) - .get_result::(conn) + .get_result::(&mut *conn) .await } } diff --git a/crates/db_schema/src/aggregates/site_aggregates.rs b/crates/db_schema/src/aggregates/site_aggregates.rs index e752c4ff6..a1bcf5bdd 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::(conn).await + site_aggregates::table.first::(&mut *conn).await } } diff --git a/crates/db_schema/src/impls/activity.rs b/crates/db_schema/src/impls/activity.rs index b271ee9be..672d831ff 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::(conn).await + activity.find(activity_id).first::(&mut *conn).await } async fn create(mut conn: impl DbConn, new_activity: &Self::InsertForm) -> Result { insert_into(activity) .values(new_activity) - .get_result::(conn) + .get_result::(&mut *conn) .await } @@ -31,12 +31,12 @@ impl Crud for Activity { ) -> Result { diesel::update(activity.find(activity_id)) .set(new_activity) - .get_result::(conn) + .get_result::(&mut *conn) .await } async fn delete(mut conn: impl DbConn, activity_id: i32) -> Result { diesel::delete(activity.find(activity_id)) - .execute(conn) + .execute(&mut *conn) .await } } @@ -48,7 +48,7 @@ impl Activity { ) -> Result { activity .filter(ap_id.eq(object_id)) - .first::(conn) + .first::(&mut *conn) .await } } diff --git a/crates/db_schema/src/impls/actor_language.rs b/crates/db_schema/src/impls/actor_language.rs index 160733251..cc4cc5389 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( - pool: &DbPool, + mut conn: impl DbConn, language_ids: Vec, for_local_user_id: LocalUserId, ) -> Result<(), Error> { - let mut lang_ids = convert_update_languages(get_conn(pool).await?, language_ids).await?; + let mut lang_ids = convert_update_languages(&mut *conn, language_ids).await?; // No need to update if languages are unchanged - let current = LocalUserLanguage::read(get_conn(pool).await?, for_local_user_id).await?; + let current = LocalUserLanguage::read(&mut *conn, for_local_user_id).await?; if current == lang_ids { return Ok(()); } @@ -84,7 +84,7 @@ impl LocalUserLanguage { lang_ids.push(UNDETERMINED_ID); } - get_conn(pool).await? + conn .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(conn) + .load(&mut *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(conn) + .load(&mut *conn) .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?; + 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?; - convert_read_languages(get_conn(pool).await?, langs).await + convert_read_languages(&mut *conn, langs).await } pub async fn update( - pool: &DbPool, + mut conn: impl DbConn, 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(get_conn(pool).await?, language_ids).await?; + let lang_ids = convert_update_languages(&mut *conn, language_ids).await?; // No need to update if languages are unchanged - let current = SiteLanguage::read(get_conn(pool).await?, site.id).await?; + let current = SiteLanguage::read(&mut *conn, site.id).await?; if current == lang_ids { return Ok(()); } - get_conn(pool).await? + conn .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(conn) + .get_result(&mut *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( - pool: &DbPool, + mut conn: impl DbConn, 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(get_conn(pool).await?) + .get_results(&mut *conn) .await?; for c in community_languages { delete(cl::community_language.filter(cl::language_id.eq(c))) - .execute(get_conn(pool).await?) + .execute(&mut *conn) .await?; } Ok(()) @@ -250,35 +250,35 @@ impl CommunityLanguage { .filter(community_id.eq(for_community_id)) .order(language_id) .select(language_id) - .get_results(conn) + .get_results(&mut *conn) .await } pub async fn read( - pool: &DbPool + mut conn: impl DbConn, for_community_id: CommunityId, ) -> Result, Error> { - let langs = Self::read_raw(get_conn(pool).await?, for_community_id).await?; - convert_read_languages(get_conn(pool).await?, langs).await + let langs = Self::read_raw(&mut *conn, for_community_id).await?; + convert_read_languages(&mut *conn, langs).await } pub async fn update( - pool: &DbPool, + mut conn: impl DbConn, mut language_ids: Vec, for_community_id: CommunityId, ) -> Result<(), Error> { if language_ids.is_empty() { - language_ids = SiteLanguage::read_local_raw(get_conn(pool).await?).await?; + language_ids = SiteLanguage::read_local_raw(&mut *conn).await?; } - let lang_ids = convert_update_languages(get_conn(pool).await?, language_ids).await?; + let lang_ids = convert_update_languages(&mut *conn, language_ids).await?; // No need to update if languages are unchanged - let current = CommunityLanguage::read_raw(get_conn(pool).await?, for_community_id).await?; + let current = CommunityLanguage::read_raw(&mut *conn, for_community_id).await?; if current == lang_ids { return Ok(()); } - get_conn(pool).await? + conn .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::(conn) + .get_results::(&mut *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(conn) + .first(&mut *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 59f049e92..3605c24f4 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::(conn) + .get_result::(&mut *conn) .await } pub async fn check_captcha( - pool: &DbPool, + mut conn: impl DbConn, 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::(get_conn(pool).await?) + .get_result::(&mut *conn) .await?; // delete checked captcha delete(captcha_answer.filter(uuid.eq(to_check.uuid))) - .execute(get_conn(pool).await?) + .execute(&mut *conn) .await?; Ok(captcha_exists) diff --git a/crates/db_schema/src/impls/comment.rs b/crates/db_schema/src/impls/comment.rs index 4a5a92dd3..4f9902531 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::(conn) + .get_results::(&mut *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::(conn) + .get_results::(&mut *conn) .await } pub async fn create( - pool: &DbPool, + mut conn: impl DbConn, 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::(get_conn(pool).await?) + .get_result::(&mut *conn) .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::(get_conn(pool).await?) + .get_result::(&mut *conn) .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(get_conn(pool).await?) + .execute(&mut *conn) .await?; } } @@ -128,7 +128,7 @@ where ca.comment_id = c.id" Ok( comment .filter(ap_id.eq(object_id)) - .first::(conn) + .first::(&mut *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::(conn).await + comment.find(comment_id).first::(&mut *conn).await } async fn delete(mut conn: impl DbConn, comment_id: CommentId) -> Result { diesel::delete(comment.find(comment_id)) - .execute(conn) + .execute(&mut *conn) .await } @@ -174,7 +174,7 @@ impl Crud for Comment { ) -> Result { diesel::update(comment.find(comment_id)) .set(comment_form) - .get_result::(conn) + .get_result::(&mut *conn) .await } } @@ -190,7 +190,7 @@ impl Likeable for CommentLike { .on_conflict((comment_id, person_id)) .do_update() .set(comment_like_form) - .get_result::(conn) + .get_result::(&mut *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(conn) + .execute(&mut *conn) .await } } @@ -222,7 +222,7 @@ impl Saveable for CommentSaved { .on_conflict((comment_id, person_id)) .do_update() .set(comment_saved_form) - .get_result::(conn) + .get_result::(&mut *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(conn) + .execute(&mut *conn) .await } } diff --git a/crates/db_schema/src/impls/comment_reply.rs b/crates/db_schema/src/impls/comment_reply.rs index 8396e96ad..4569082f3 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::(conn) + .first::(&mut *conn) .await } @@ -31,7 +31,7 @@ impl Crud for CommentReply { .on_conflict((recipient_id, comment_id)) .do_update() .set(comment_reply_form) - .get_result::(conn) + .get_result::(&mut *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::(conn) + .get_result::(&mut *conn) .await } } @@ -58,7 +58,7 @@ impl CommentReply { .filter(read.eq(false)), ) .set(read.eq(true)) - .get_results::(conn) + .get_results::(&mut *conn) .await } @@ -68,7 +68,7 @@ impl CommentReply { ) -> Result { comment_reply .filter(comment_id.eq(for_comment_id)) - .first::(conn) + .first::(&mut *conn) .await } } diff --git a/crates/db_schema/src/impls/comment_report.rs b/crates/db_schema/src/impls/comment_report.rs index 94a6af937..e78bae0d6 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::(conn) + .get_result::(&mut *conn) .await } @@ -47,7 +47,7 @@ impl Reportable for CommentReport { resolver_id.eq(by_resolver_id), updated.eq(naive_now()), )) - .execute(conn) + .execute(&mut *conn) .await } @@ -67,7 +67,7 @@ impl Reportable for CommentReport { resolver_id.eq(by_resolver_id), updated.eq(naive_now()), )) - .execute(conn) + .execute(&mut *conn) .await } } diff --git a/crates/db_schema/src/impls/community.rs b/crates/db_schema/src/impls/community.rs index 3d8d52d37..6b0cb196c 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::(conn) + .first::(&mut *conn) .await } async fn delete(mut conn: impl DbConn, community_id: CommunityId) -> Result { diesel::delete(community::table.find(community_id)) - .execute(conn) + .execute(&mut *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(conn, id) + Some(id) => Community::read_from_apub_id(&mut *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 c88ba2a91..041440244 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::(conn) + .get_result::(&mut *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(conn) + .execute(&mut *conn) .await } }