From 730893883bb17044ebfc7999bfd36030ab318e0f Mon Sep 17 00:00:00 2001 From: bush1D3v Date: Sun, 28 Jul 2024 20:59:48 -0300 Subject: [PATCH] refactor: The borrowed expression implements the required traits --- src/modules/user/user_controllers.rs | 4 ++-- src/modules/user/user_queues.rs | 6 +++--- src/modules/user/user_services.rs | 13 ++++++------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/modules/user/user_controllers.rs b/src/modules/user/user_controllers.rs index 7cfd478..2771583 100644 --- a/src/modules/user/user_controllers.rs +++ b/src/modules/user/user_controllers.rs @@ -276,8 +276,8 @@ async fn login_user_response_constructor( string_user: &str, email: &str, ) -> HttpResponse { - let _ = Redis::set(&redis_pool, &service_resp.user.id, &string_user).await; - let _ = Redis::set(&redis_pool, email, string_user).await; + let _ = Redis::set(redis_pool, &service_resp.user.id, string_user).await; + let _ = Redis::set(redis_pool, email, string_user).await; HttpResponse::Ok().json(LoginUserControllerResponse { access_token: service_resp.access_token, access_expires_in: service_resp.access_expires_in, diff --git a/src/modules/user/user_queues.rs b/src/modules/user/user_queues.rs index d6fe381..243ddf2 100644 --- a/src/modules/user/user_queues.rs +++ b/src/modules/user/user_queues.rs @@ -108,9 +108,9 @@ async fn put_user_queue(pool: Pool, queue: Arc) -> Result<(), H let mut sql_builder = sql_builder::SqlBuilder::update_table("users"); sql_builder.set("password", "e(&user.new_password)); - sql_builder.set("email", "e(user.new_email.clone())); - sql_builder.set("updated_at", "e(updated_at)); - sql_builder.or_where_eq("id", "e(&user_id)); + sql_builder.set("email", "e(&user.new_email)); + sql_builder.set("updated_at", "e(&updated_at)); + sql_builder.or_where_eq("id", "e(user_id)); let mut this_sql = match sql_builder.sql() { Ok(x) => x, diff --git a/src/modules/user/user_services.rs b/src/modules/user/user_services.rs index af7afd4..1d3ca93 100644 --- a/src/modules/user/user_services.rs +++ b/src/modules/user/user_services.rs @@ -135,18 +135,17 @@ pub async fn delete_user_service( user_id: String, string_user: Option, ) -> Result { - let db_user: UserDTO; - if string_user == None { - db_user = match detail_user_repository(pg_pool.clone(), user_id.clone()).await { + let db_user: UserDTO = if string_user.is_none() { + match detail_user_repository(pg_pool.clone(), user_id.clone()).await { Ok(user_dto) => user_dto, Err(e) => return Err(e), - }; + } } else { - db_user = match UserSerdes::serde_string_to_json(&string_user.unwrap()) { + match UserSerdes::serde_string_to_json(&string_user.unwrap()) { Ok(user_dto) => user_dto, Err(e) => return Err(e), - }; - } + } + }; match password_verifier( pg_pool,