type InsertForm = PersonInsertForm;
type UpdateForm = PersonUpdateForm;
type IdType = PersonId;
- async fn read(pool: &DbPool, person_id: PersonId) -> Result<Self, Error> {
+ async fn read(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
person::table
.filter(person::deleted.eq(false))
.first::<Self>(conn)
.await
}
- async fn delete(pool: &DbPool, person_id: PersonId) -> Result<usize, Error> {
+ async fn delete(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<usize, Error> {
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<Self, Error> {
+ async fn create(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(person::table)
.values(form)
.await
}
async fn update(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
person_id: PersonId,
form: &PersonUpdateForm,
) -> Result<Self, Error> {
/// 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<Self, Error> {
+ pub async fn upsert(pool: &mut DbPool<'_>, form: &PersonInsertForm) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
insert_into(person::table)
.values(form)
.get_result::<Self>(conn)
.await
}
- pub async fn delete_account(pool: &DbPool, person_id: PersonId) -> Result<Person, Error> {
+ pub async fn delete_account(pool: &mut DbPool<'_>, person_id: PersonId) -> Result<Person, Error> {
let conn = &mut get_conn(pool).await?;
// Set the local user info to none
#[async_trait]
impl ApubActor for Person {
- async fn read_from_apub_id(pool: &DbPool, object_id: &DbUrl) -> Result<Option<Self>, Error> {
+ async fn read_from_apub_id(
+ pool: &mut DbPool<'_>,
+ object_id: &DbUrl,
+ ) -> Result<Option<Self>, Error> {
let conn = &mut get_conn(pool).await?;
Ok(
person::table
}
async fn read_from_name(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
from_name: &str,
include_deleted: bool,
) -> Result<Person, Error> {
}
async fn read_from_name_and_domain(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
person_name: &str,
for_domain: &str,
) -> Result<Person, Error> {
#[async_trait]
impl Followable for PersonFollower {
type Form = PersonFollowerForm;
- async fn follow(pool: &DbPool, form: &PersonFollowerForm) -> Result<Self, Error> {
+ async fn follow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result<Self, Error> {
use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id};
let conn = &mut get_conn(pool).await?;
insert_into(person_follower)
.get_result::<Self>(conn)
.await
}
- async fn follow_accepted(_: &DbPool, _: CommunityId, _: PersonId) -> Result<Self, Error> {
+ async fn follow_accepted(_: &mut DbPool<'_>, _: CommunityId, _: PersonId) -> Result<Self, Error> {
unimplemented!()
}
- async fn unfollow(pool: &DbPool, form: &PersonFollowerForm) -> Result<usize, Error> {
+ async fn unfollow(pool: &mut DbPool<'_>, form: &PersonFollowerForm) -> Result<usize, Error> {
use crate::schema::person_follower::dsl::{follower_id, person_follower, person_id};
let conn = &mut get_conn(pool).await?;
diesel::delete(
impl PersonFollower {
pub async fn list_followers(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
for_person_id: PersonId,
) -> Result<Vec<Person>, Error> {
let conn = &mut get_conn(pool).await?;
#[cfg(test)]
mod tests {
+ #![allow(clippy::unwrap_used)]
+ #![allow(clippy::indexing_slicing)]
+
use crate::{
source::{
instance::Instance,
#[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
#[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();