diff --git a/Cargo.toml b/Cargo.toml index 4ed99f9..2f3c531 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,17 +35,17 @@ actix-files = "0.6.2" actix-multipart = "0.6.0" actix-service = "2.0.2" actix-web = "4.3.1" -actix-web-grants = "3.0.1" +actix-web-grants = "3.0.2" actix-ws = "0.2.5" # actix-ratelimit = "*" -anyhow = "1.0.71" -argon2 = "0.5.0" -async-trait = "0.1.68" +anyhow = "1.0.75" +argon2 = "0.5.1" +async-trait = "0.1.73" base64 = "0.21.2" chrono = {version = "0.4.26", default-features = false, features = ["clock", "serde"]} config = "0.13.3" derive_more = "0.99.17" -fake = {version = "2.6.1", features = ["derive", "uuid", "chrono"]} +fake = {version = "2.7.0", features = ["derive", "uuid", "chrono"]} futures = "0.3.28" hex = "0.4.3" hex-literal = "0.4.1" @@ -53,51 +53,50 @@ hmac = "0.12.1" itertools = "0.11.0" jsonwebtoken = "8.3.0" lettre = {version = "0.10.4", features = ["tokio1-native-tls", "builder"]} -log = "0.4.19" +log = "0.4.20" log-derive = "0.4.1" mockall = "0.11.4" once_cell = "1.18.0" -openssl = "0.10.55" +openssl = "0.10.56" project-root = "0.2.2" rand = "0.8.5" rand_core = {version = "0.6.4", features = ["std"]} -redis = {version = "0.23.0", features = ["tokio-comp"]} +redis = {version = "0.23.2", features = ["tokio-comp"]} reqwest = {version = "0.11.18", features = ["json", "multipart", "stream"]} -sanitize-filename = "0.4.0" -scraper = "0.16.0" +sanitize-filename = "0.5.0" +scraper = "0.17.1" sentry = "0.31.5" sentry-actix = "0.31.5" -serde = {version = "1.0.164", features = ["derive"]} -serde_json = "1.0.99" +serde = {version = "1.0.185", features = ["derive"]} +serde_json = "1.0.105" sha2 = "0.10.7" -sqlx = {version = "0.6.3", default-features = false, features = [ +sqlx = {version = "0.7.1", default-features = false, features = [ "postgres", "runtime-tokio-rustls", "chrono", "uuid", "macros", "migrate", - "offline", ]} strum = {version = "0.25.0", features = ["derive"]} -tempfile = "3.6.0" +tempfile = "3.8.0" tera = "1.19.0" test-context = "0.1.4" -thiserror = "1.0.40" -tokio = {version = "1.28.2", features = ["full"]} +thiserror = "1.0.47" +tokio = {version = "1.32.0", features = ["full"]} tracing = "0.1.37" -tracing-actix-web = "0.7.5" +tracing-actix-web = "0.7.6" tracing-appender = "0.2.2" -tracing-bunyan-formatter = "0.3.7" +tracing-bunyan-formatter = "0.3.9" tracing-log = "0.1.3" tracing-subscriber = {version = "0.3.17", features = [ "registry", "env-filter", ]} url = "2.4.0" -utoipa = {version = "3.3.0", features = ["actix_extras", "uuid", "chrono"]} -utoipa-swagger-ui = {version = "3.1.3", features = ["actix-web"]} -uuid = {version = "1.3.4", features = ["v4", "serde"]} +utoipa = {version = "3.5.0", features = ["actix_extras", "uuid", "chrono"]} +utoipa-swagger-ui = {version = "3.1.5", features = ["actix-web"]} +uuid = {version = "1.4.1", features = ["v4", "serde"]} validator = {version = "0.16.1", features = ["derive"]} wiremock = "0.5.19" # phf = {version= "0.11.1",features = ["macros"]} diff --git a/base-query-derive/Cargo.toml b/base-query-derive/Cargo.toml index 70f87c8..43dd4d7 100644 --- a/base-query-derive/Cargo.toml +++ b/base-query-derive/Cargo.toml @@ -10,7 +10,7 @@ proc-macro = true base-query = {path = "../base-query"} itertools = {workspace = true} model = {path = "../model"} -proc-macro2 = "1.0.60" -quote = "1.0.28" +proc-macro2 = "1.0.66" +quote = "1.0.33" sqlx = {workspace = true} -syn = "2.0.20" +syn = "2.0.29" diff --git a/query/src/lib.rs b/query/src/lib.rs index de57a12..406a985 100644 --- a/query/src/lib.rs +++ b/query/src/lib.rs @@ -21,7 +21,7 @@ where // .execute(&mut tx) // .await?; sqlx::query!(r#"SET statement_timeout=1000;"#) - .execute(&mut tx) + .execute(&mut *tx) .await?; let (output, tx) = f(tx).await?; tx.commit().await?; diff --git a/query/src/user.rs b/query/src/user.rs index 7398730..c5f9ff0 100644 --- a/query/src/user.rs +++ b/query/src/user.rs @@ -151,7 +151,7 @@ mod tests { for user in users.iter_mut() { user.create_at = None; user.update_at = None; - save(user).execute(&mut tx_ctx.tx).await.unwrap(); + save(user).execute(&mut *tx_ctx.tx).await.unwrap(); } Self { tx_ctx, users } } @@ -167,10 +167,10 @@ mod tests { let mut user: User = Faker.fake(); user.create_at = None; user.update_at = None; - let result = save(&user).execute(&mut ctx.tx_ctx.tx).await.unwrap(); + let result = save(&user).execute(&mut *ctx.tx_ctx.tx).await.unwrap(); assert_eq!(result.rows_affected(), 1); let result = find_by_id(&user.id) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert_eq!(result.id, user.id); @@ -186,23 +186,23 @@ mod tests { async fn test_repo_exist_user_by_username_or_email_repo(ctx: &mut UserTxRepoTestContext) { let user = ctx.users.choose(&mut rand::thread_rng()).unwrap(); let result = exist_by_username_or_email(&user.username, &user.email, Some(user.is_active)) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert!(result.exist.unwrap()); let result = exist_by_username_or_email(&user.username, "fake_user1234@mail.com", None) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert!(result.exist.unwrap()); let result = exist_by_username_or_email(&user.username, &user.email, None) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert!(result.exist.unwrap()); let result = exist_by_username_or_email("fake_username", "fake_user@mail.com", Some(user.is_active)) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert!(!result.exist.unwrap()); @@ -213,7 +213,7 @@ mod tests { async fn test_repo_find_user_by_email(ctx: &mut UserTxRepoTestContext) { let user = ctx.users.choose(&mut rand::thread_rng()).unwrap(); let result = find_by_email(&user.email, Some(user.is_active)) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert_eq!(result.username, user.username); @@ -228,14 +228,14 @@ mod tests { sort_by: Some("username".to_string()), sort_direction: Some(Direction::ASC), }; - let result1 = find_page(req).fetch_all(&mut ctx.tx_ctx.tx).await.unwrap(); + let result1 = find_page(req).fetch_all(&mut *ctx.tx_ctx.tx).await.unwrap(); let req = PageParamQuery { page_num: 2, page_size: 2, sort_by: Some("username".to_string()), sort_direction: Some(Direction::ASC), }; - let result2 = find_page(req).fetch_all(&mut ctx.tx_ctx.tx).await.unwrap(); + let result2 = find_page(req).fetch_all(&mut *ctx.tx_ctx.tx).await.unwrap(); assert_eq!(result1.len(), 2); assert_eq!(result2.len(), 2); } @@ -248,10 +248,10 @@ mod tests { let new_pass: String = Faker.fake(); user.password = new_pass.clone(); let expected_pass = new_pass.clone(); - update(&user).execute(&mut ctx.tx_ctx.tx).await.unwrap(); + update(&user).execute(&mut *ctx.tx_ctx.tx).await.unwrap(); let user_id = user.id; let result = find_by_id(&user_id) - .fetch_one(&mut ctx.tx_ctx.tx) + .fetch_one(&mut *ctx.tx_ctx.tx) .await .unwrap(); assert_eq!(result.password, expected_pass); diff --git a/service/src/admin/user.rs b/service/src/admin/user.rs index 2dceff9..aa76ed8 100644 --- a/service/src/admin/user.rs +++ b/service/src/admin/user.rs @@ -8,9 +8,9 @@ pub async fn list( ) -> AppResult> { query::get_transaction(pg_client, move |mut tx| async move { let data = query::user::find_page(page.clone()) - .fetch_all(&mut tx) + .fetch_all(&mut *tx) .await?; - let total = query::user::count_all().fetch_one(&mut tx).await?; + let total = query::user::count_all().fetch_one(&mut *tx).await?; let resp = PageResponse { data: data .into_iter() diff --git a/service/src/user.rs b/service/src/user.rs index c816592..92b0c8d 100644 --- a/service/src/user.rs +++ b/service/src/user.rs @@ -48,7 +48,7 @@ pub async fn register( }; let state_clone = state.clone(); let user_id = query::get_transaction(&state.postgres, move |mut tx| async move { - query::user::save(&user).execute(&mut tx).await?; + query::user::save(&user).execute(&mut *tx).await?; crate::email::send_email( &state_clone.email, &invitation, @@ -94,7 +94,7 @@ pub async fn active(state: &AppState, req: ActiveRequest) -> AppResult { query::get_transaction(&state.postgres, move |mut tx| async move { let mut user = fetch_user_by_id(&mut tx, &value.user_id).await?; user.is_active = true; - query::user::update(&user).execute(&mut tx).await?; + query::user::update(&user).execute(&mut *tx).await?; Ok(((), tx)) }) .await?; @@ -222,7 +222,7 @@ pub async fn reset_password(state: &AppState, req: SetPasswordRequest) -> AppRes query::get_transaction(&state.postgres, move |mut tx| async move { let mut user = fetch_active_user_by_id(&mut tx, &value.user_id).await?; user.password = password; - query::user::update(&user).execute(&mut tx).await?; + query::user::update(&user).execute(&mut *tx).await?; Ok(((), tx)) }) .await?; @@ -266,7 +266,7 @@ pub async fn update_profile( if let Some(password) = req.password { user.password = password; } - query::user::update(&user).execute(&mut tx).await?; + query::user::update(&user).execute(&mut *tx).await?; Ok(((), tx)) }) .await?; @@ -278,7 +278,7 @@ pub async fn fetch_user_by_id( user_id: &Uuid, ) -> AppResult { let user = query::user::find_by_id(user_id) - .fetch_optional(tx) + .fetch_optional(&mut **tx) .await? .ok_or_else(|| AppError::NotFound("No User Found with This ID".to_string()))?; Ok(user)