X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_schema%2Fsrc%2Fimpls%2Fperson.rs;h=2e086dcb6d3f1cb9a8eda5ec61ec38ca9b142103;hb=92568956353f21649ed9aff68b42699c9d036f30;hp=5c23f8071a2adbd3eb973b6ae6d577a8f6bf6687;hpb=e3eda68147f76c654b54cf0a5702ef90b5dd8efe;p=lemmy.git diff --git a/crates/db_schema/src/impls/person.rs b/crates/db_schema/src/impls/person.rs index 5c23f807..2e086dcb 100644 --- a/crates/db_schema/src/impls/person.rs +++ b/crates/db_schema/src/impls/person.rs @@ -19,7 +19,7 @@ impl Crud for Person { type InsertForm = PersonInsertForm; type UpdateForm = PersonUpdateForm; type IdType = PersonId; - async fn read(pool: &DbPool, person_id: PersonId) -> Result { + async fn read(pool: &mut DbPool<'_>, person_id: PersonId) -> Result { let conn = &mut get_conn(pool).await?; person::table .filter(person::deleted.eq(false)) @@ -27,13 +27,13 @@ impl Crud for Person { .first::(conn) .await } - async fn delete(pool: &DbPool, person_id: PersonId) -> Result { + async fn delete(pool: &mut DbPool<'_>, person_id: PersonId) -> Result { let conn = &mut get_conn(pool).await?; diesel::delete(person::table.find(person_id)) .execute(conn) .await } - async fn create(pool: &DbPool, form: &PersonInsertForm) -> Result { + async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(person::table) .values(form) @@ -41,7 +41,7 @@ impl Crud for Person { .await } async fn update( - pool: &DbPool, + pool: &mut DbPool<'_>, person_id: PersonId, form: &PersonUpdateForm, ) -> Result { @@ -57,7 +57,7 @@ impl Person { /// Update or insert the person. /// /// This is necessary for federation, because Activitypub doesnt distinguish between these actions. - pub async fn upsert(pool: &DbPool, form: &PersonInsertForm) -> Result { + pub async fn upsert(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result { let conn = &mut get_conn(pool).await?; insert_into(person::table) .values(form) @@ -67,7 +67,7 @@ impl Person { .get_result::(conn) .await } - pub async fn delete_account(pool: &DbPool, person_id: PersonId) -> Result { + pub async fn delete_account(pool: &mut DbPool<'_>, person_id: PersonId) -> Result { let conn = &mut get_conn(pool).await?; // Set the local user info to none @@ -104,7 +104,10 @@ pub fn is_banned(banned_: bool, expires: Option) -> bool #[async_trait] impl ApubActor for Person { - async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result, Error> { + async fn read_from_apub_id( + pool: &mut DbPool<'_>, + object_id: &DbUrl, + ) -> Result, Error> { let conn = &mut get_conn(pool).await?; Ok( person::table @@ -118,7 +121,7 @@ impl ApubActor for Person { } async fn read_from_name( - pool: &DbPool, + pool: &mut DbPool<'_>, from_name: &str, include_deleted: bool, ) -> Result { @@ -134,7 +137,7 @@ impl ApubActor for Person { } async fn read_from_name_and_domain( - pool: &DbPool, + pool: &mut DbPool<'_>, person_name: &str, for_domain: &str, ) -> Result { @@ -153,7 +156,7 @@ impl ApubActor for Person { #[async_trait] impl Followable for PersonFollower { type Form = PersonFollowerForm; - async fn follow(pool: &DbPool, form: &PersonFollowerForm) -> Result { + async fn follow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result { use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id}; let conn = &mut get_conn(pool).await?; insert_into(person_follower) @@ -164,10 +167,10 @@ impl Followable for PersonFollower { .get_result::(conn) .await } - async fn follow_accepted(_: &DbPool, _: CommunityId, _: PersonId) -> Result { + async fn follow_accepted(_: &mut DbPool<'_>, _: CommunityId, _: PersonId) -> Result { unimplemented!() } - async fn unfollow(pool: &DbPool, form: &PersonFollowerForm) -> Result { + async fn unfollow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result { use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id}; let conn = &mut get_conn(pool).await?; diesel::delete( @@ -182,7 +185,7 @@ impl Followable for PersonFollower { impl PersonFollower { pub async fn list_followers( - pool: &DbPool, + pool: &mut DbPool<'_>, for_person_id: PersonId, ) -> Result, Error> { let conn = &mut get_conn(pool).await?; @@ -197,6 +200,9 @@ impl PersonFollower { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] + #![allow(clippy::indexing_slicing)] + use crate::{ source::{ instance::Instance, @@ -211,6 +217,7 @@ mod tests { #[serial] async fn test_crud() { let pool = &build_db_pool_for_tests().await; + let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()) .await @@ -271,6 +278,7 @@ mod tests { #[serial] async fn follow() { let pool = &build_db_pool_for_tests().await; + let pool = &mut pool.into(); let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string()) .await .unwrap();