type InsertForm = CommunityInsertForm;
type UpdateForm = CommunityUpdateForm;
type IdType = CommunityId;
- async fn read(pool: &DbPool, community_id: CommunityId) -> Result<Self, Error> {
+ async fn read(pool: &mut DbPool<'_>, community_id: CommunityId) -> Result<Self, Error> {
let conn = &mut get_conn(pool).await?;
community::table
.find(community_id)
.await
}
- async fn delete(pool: &DbPool, community_id: CommunityId) -> Result<usize, Error> {
+ async fn delete(pool: &mut DbPool<'_>, community_id: CommunityId) -> Result<usize, Error> {
let conn = &mut get_conn(pool).await?;
diesel::delete(community::table.find(community_id))
.execute(conn)
.await
}
- async fn create(pool: &DbPool, form: &Self::InsertForm) -> Result<Self, Error> {
- let conn = &mut get_conn(pool).await?;
+ async fn create(pool: &mut DbPool<'_>, form: &Self::InsertForm) -> Result<Self, Error> {
let is_new_community = match &form.actor_id {
Some(id) => Community::read_from_apub_id(pool, id).await?.is_none(),
None => true,
};
+ let conn = &mut get_conn(pool).await?;
// Can't do separate insert/update commands because InsertForm/UpdateForm aren't convertible
let community_ = insert_into(community::table)
}
async fn update(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_id: CommunityId,
form: &Self::UpdateForm,
) -> Result<Self, Error> {
impl Joinable for CommunityModerator {
type Form = CommunityModeratorForm;
async fn join(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_moderator_form: &CommunityModeratorForm,
) -> Result<Self, Error> {
use crate::schema::community_moderator::dsl::community_moderator;
}
async fn leave(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_moderator_form: &CommunityModeratorForm,
) -> Result<usize, Error> {
use crate::schema::community_moderator::dsl::{community_id, community_moderator, person_id};
impl Community {
/// Get the community which has a given moderators or featured url, also return the collection type
pub async fn get_by_collection_url(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
url: &DbUrl,
) -> Result<(Community, CollectionType), Error> {
use crate::schema::community::dsl::{featured_url, moderators_url};
impl CommunityModerator {
pub async fn delete_for_community(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
for_community_id: CommunityId,
) -> Result<usize, Error> {
use crate::schema::community_moderator::dsl::{community_id, community_moderator};
}
pub async fn leave_all_communities(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
for_person_id: PersonId,
) -> Result<usize, Error> {
use crate::schema::community_moderator::dsl::{community_moderator, person_id};
}
pub async fn get_person_moderated_communities(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
for_person_id: PersonId,
) -> Result<Vec<CommunityId>, Error> {
use crate::schema::community_moderator::dsl::{community_id, community_moderator, person_id};
impl Bannable for CommunityPersonBan {
type Form = CommunityPersonBanForm;
async fn ban(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_person_ban_form: &CommunityPersonBanForm,
) -> Result<Self, Error> {
use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id};
}
async fn unban(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_person_ban_form: &CommunityPersonBanForm,
) -> Result<usize, Error> {
use crate::schema::community_person_ban::dsl::{community_id, community_person_ban, person_id};
#[async_trait]
impl Followable for CommunityFollower {
type Form = CommunityFollowerForm;
- async fn follow(pool: &DbPool, form: &CommunityFollowerForm) -> Result<Self, Error> {
+ async fn follow(pool: &mut DbPool<'_>, form: &CommunityFollowerForm) -> Result<Self, Error> {
use crate::schema::community_follower::dsl::{community_follower, community_id, person_id};
let conn = &mut get_conn(pool).await?;
insert_into(community_follower)
.await
}
async fn follow_accepted(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_id_: CommunityId,
person_id_: PersonId,
) -> Result<Self, Error> {
.get_result::<Self>(conn)
.await
}
- async fn unfollow(pool: &DbPool, form: &CommunityFollowerForm) -> Result<usize, Error> {
+ async fn unfollow(pool: &mut DbPool<'_>, form: &CommunityFollowerForm) -> Result<usize, Error> {
use crate::schema::community_follower::dsl::{community_follower, community_id, person_id};
let conn = &mut get_conn(pool).await?;
diesel::delete(
#[async_trait]
impl ApubActor for Community {
- 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(
community::table
}
async fn read_from_name(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_name: &str,
include_deleted: bool,
) -> Result<Community, Error> {
}
async fn read_from_name_and_domain(
- pool: &DbPool,
+ pool: &mut DbPool<'_>,
community_name: &str,
for_domain: &str,
) -> Result<Community, Error> {
#[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