]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/federation_allowlist.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_schema / src / impls / federation_allowlist.rs
index c71ffd1cf3088d6b850fef2c251be4834d978ac1..d4aed484655b26a6c03c058b5e13b90f3b06ad90 100644 (file)
@@ -10,7 +10,7 @@ use diesel::{dsl::insert_into, result::Error};
 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()
@@ -21,7 +21,7 @@ impl FederationAllowList {
 
             for domain in list {
               // Upsert all of these as instances
-              let instance = Instance::read_or_create_with_conn(conn, domain).await?;
+              let instance = Instance::read_or_create(&mut conn.into(), domain).await?;
 
               let form = FederationAllowListForm {
                 instance_id: instance.id,
@@ -59,6 +59,7 @@ mod tests {
   #[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(),