use diesel_async::{AsyncPgConnection, RunQueryDsl};
impl FederationAllowList {
- pub async fn replace(pool: &DbPool, list_opt: Option<Vec<String>>) -> Result<(), Error> {
+ pub async fn replace(pool: &mut DbPool<'_>, list_opt: Option<Vec<String>>) -> Result<(), Error> {
let conn = &mut get_conn(pool).await?;
conn
.build_transaction()
for domain in list {
// Upsert all of these as instances
- let instance = Instance::create_conn(conn, &domain).await?;
+ let instance = Instance::read_or_create(&mut conn.into(), domain).await?;
let form = FederationAllowListForm {
instance_id: instance.id,
#[serial]
async fn test_allowlist_insert_and_clear() {
let pool = &build_db_pool_for_tests().await;
+ let pool = &mut pool.into();
let domains = vec![
"tld1.xyz".to_string(),
"tld2.xyz".to_string(),