style: apply cargo fmt to entire codebase
Standardize code formatting across all 173 Rust source files using rustfmt. No functional changes - purely cosmetic. This establishes a consistent code style baseline for the project going forward.
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
use async_trait::async_trait;
|
||||
use futures::future::BoxFuture;
|
||||
use sqlx::{PgPool, Row};
|
||||
use std::sync::Arc;
|
||||
use futures::future::BoxFuture;
|
||||
|
||||
use crate::domain::entities::user::{User, UserRole};
|
||||
use crate::domain::repositories::user_repository::{UserRepository, UserRepositoryError, UserRepositoryResult, StorageStats};
|
||||
use crate::application::ports::auth_ports::UserStoragePort;
|
||||
use crate::common::errors::DomainError;
|
||||
use crate::domain::entities::user::{User, UserRole};
|
||||
use crate::domain::repositories::user_repository::{
|
||||
StorageStats, UserRepository, UserRepositoryError, UserRepositoryResult,
|
||||
};
|
||||
use crate::infrastructure::repositories::pg::transaction_utils::with_transaction;
|
||||
|
||||
// Implement From<sqlx::Error> for UserRepositoryError to allow automatic conversions
|
||||
@@ -24,28 +26,20 @@ impl UserPgRepository {
|
||||
pub fn new(pool: Arc<PgPool>) -> Self {
|
||||
Self { pool }
|
||||
}
|
||||
|
||||
|
||||
// Helper method to map SQL errors to domain errors
|
||||
pub fn map_sqlx_error(err: sqlx::Error) -> UserRepositoryError {
|
||||
match err {
|
||||
sqlx::Error::RowNotFound => {
|
||||
UserRepositoryError::NotFound("User not found".to_string())
|
||||
},
|
||||
sqlx::Error::RowNotFound => UserRepositoryError::NotFound("User not found".to_string()),
|
||||
sqlx::Error::Database(db_err) => {
|
||||
if db_err.code().is_some_and(|code| code == "23505") {
|
||||
// PostgreSQL uniqueness violation code
|
||||
UserRepositoryError::AlreadyExists(
|
||||
"User or email already exists".to_string()
|
||||
)
|
||||
UserRepositoryError::AlreadyExists("User or email already exists".to_string())
|
||||
} else {
|
||||
UserRepositoryError::DatabaseError(
|
||||
format!("Database error: {}", db_err)
|
||||
)
|
||||
UserRepositoryError::DatabaseError(format!("Database error: {}", db_err))
|
||||
}
|
||||
},
|
||||
_ => UserRepositoryError::DatabaseError(
|
||||
format!("Database error: {}", err)
|
||||
),
|
||||
}
|
||||
_ => UserRepositoryError::DatabaseError(format!("Database error: {}", err)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,21 +50,18 @@ impl UserRepository for UserPgRepository {
|
||||
async fn create_user(&self, user: User) -> UserRepositoryResult<User> {
|
||||
// Create a copy of the user for the closure
|
||||
let user_clone = user.clone();
|
||||
|
||||
with_transaction(
|
||||
&self.pool,
|
||||
"create_user",
|
||||
|tx| {
|
||||
// We need to move the closure into a BoxFuture to return inside
|
||||
// the with_transaction call
|
||||
Box::pin(async move {
|
||||
// Use getters to extract the values
|
||||
// Convert user.role() to string to pass it as plain text
|
||||
let role_str = user_clone.role().to_string();
|
||||
|
||||
// Modify the SQL to do an explicit cast to the auth.userrole type
|
||||
let _result = sqlx::query(
|
||||
r#"
|
||||
|
||||
with_transaction(&self.pool, "create_user", |tx| {
|
||||
// We need to move the closure into a BoxFuture to return inside
|
||||
// the with_transaction call
|
||||
Box::pin(async move {
|
||||
// Use getters to extract the values
|
||||
// Convert user.role() to string to pass it as plain text
|
||||
let role_str = user_clone.role().to_string();
|
||||
|
||||
// Modify the SQL to do an explicit cast to the auth.userrole type
|
||||
let _result = sqlx::query(
|
||||
r#"
|
||||
INSERT INTO auth.users (
|
||||
id, username, email, password_hash, role,
|
||||
storage_quota_bytes, storage_used_bytes,
|
||||
@@ -81,36 +72,36 @@ impl UserRepository for UserPgRepository {
|
||||
$12, $13
|
||||
)
|
||||
RETURNING *
|
||||
"#
|
||||
)
|
||||
.bind(user_clone.id())
|
||||
.bind(user_clone.username())
|
||||
.bind(user_clone.email())
|
||||
.bind(user_clone.password_hash())
|
||||
.bind(&role_str) // Convert to string but with explicit cast in SQL
|
||||
.bind(user_clone.storage_quota_bytes())
|
||||
.bind(user_clone.storage_used_bytes())
|
||||
.bind(user_clone.created_at())
|
||||
.bind(user_clone.updated_at())
|
||||
.bind(user_clone.last_login_at())
|
||||
.bind(user_clone.is_active())
|
||||
.bind(user_clone.oidc_provider())
|
||||
.bind(user_clone.oidc_subject())
|
||||
.execute(&mut **tx)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
// We could perform additional operations here,
|
||||
// such as configuring permissions, roles, etc.
|
||||
|
||||
Ok(user_clone)
|
||||
}) as BoxFuture<'_, UserRepositoryResult<User>>
|
||||
}
|
||||
).await?;
|
||||
|
||||
"#,
|
||||
)
|
||||
.bind(user_clone.id())
|
||||
.bind(user_clone.username())
|
||||
.bind(user_clone.email())
|
||||
.bind(user_clone.password_hash())
|
||||
.bind(&role_str) // Convert to string but with explicit cast in SQL
|
||||
.bind(user_clone.storage_quota_bytes())
|
||||
.bind(user_clone.storage_used_bytes())
|
||||
.bind(user_clone.created_at())
|
||||
.bind(user_clone.updated_at())
|
||||
.bind(user_clone.last_login_at())
|
||||
.bind(user_clone.is_active())
|
||||
.bind(user_clone.oidc_provider())
|
||||
.bind(user_clone.oidc_subject())
|
||||
.execute(&mut **tx)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
// We could perform additional operations here,
|
||||
// such as configuring permissions, roles, etc.
|
||||
|
||||
Ok(user_clone)
|
||||
}) as BoxFuture<'_, UserRepositoryResult<User>>
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(user) // Return the original user for simplicity
|
||||
}
|
||||
|
||||
|
||||
/// Gets a user by ID
|
||||
async fn get_user_by_id(&self, id: &str) -> UserRepositoryResult<User> {
|
||||
let row = sqlx::query(
|
||||
@@ -122,7 +113,7 @@ impl UserRepository for UserPgRepository {
|
||||
oidc_provider, oidc_subject
|
||||
FROM auth.users
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(id)
|
||||
.fetch_one(&*self.pool)
|
||||
@@ -135,7 +126,7 @@ impl UserRepository for UserPgRepository {
|
||||
Some("admin") => UserRole::Admin,
|
||||
_ => UserRole::User,
|
||||
};
|
||||
|
||||
|
||||
Ok(User::from_data_full(
|
||||
row.get("id"),
|
||||
row.get("username"),
|
||||
@@ -152,7 +143,7 @@ impl UserRepository for UserPgRepository {
|
||||
row.get("oidc_subject"),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
/// Gets a user by username
|
||||
async fn get_user_by_username(&self, username: &str) -> UserRepositoryResult<User> {
|
||||
let row = sqlx::query(
|
||||
@@ -164,7 +155,7 @@ impl UserRepository for UserPgRepository {
|
||||
oidc_provider, oidc_subject
|
||||
FROM auth.users
|
||||
WHERE username = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(username)
|
||||
.fetch_one(&*self.pool)
|
||||
@@ -177,7 +168,7 @@ impl UserRepository for UserPgRepository {
|
||||
Some("admin") => UserRole::Admin,
|
||||
_ => UserRole::User,
|
||||
};
|
||||
|
||||
|
||||
Ok(User::from_data_full(
|
||||
row.get("id"),
|
||||
row.get("username"),
|
||||
@@ -194,7 +185,7 @@ impl UserRepository for UserPgRepository {
|
||||
row.get("oidc_subject"),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
/// Gets a user by email
|
||||
async fn get_user_by_email(&self, email: &str) -> UserRepositoryResult<User> {
|
||||
let row = sqlx::query(
|
||||
@@ -206,7 +197,7 @@ impl UserRepository for UserPgRepository {
|
||||
oidc_provider, oidc_subject
|
||||
FROM auth.users
|
||||
WHERE email = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(email)
|
||||
.fetch_one(&*self.pool)
|
||||
@@ -219,7 +210,7 @@ impl UserRepository for UserPgRepository {
|
||||
Some("admin") => UserRole::Admin,
|
||||
_ => UserRole::User,
|
||||
};
|
||||
|
||||
|
||||
Ok(User::from_data_full(
|
||||
row.get("id"),
|
||||
row.get("username"),
|
||||
@@ -236,20 +227,17 @@ impl UserRepository for UserPgRepository {
|
||||
row.get("oidc_subject"),
|
||||
))
|
||||
}
|
||||
|
||||
|
||||
/// Updates an existing user using a transaction
|
||||
async fn update_user(&self, user: User) -> UserRepositoryResult<User> {
|
||||
// Create a copy of the user for the closure
|
||||
let user_clone = user.clone();
|
||||
|
||||
with_transaction(
|
||||
&self.pool,
|
||||
"update_user",
|
||||
|tx| {
|
||||
Box::pin(async move {
|
||||
// Update the user
|
||||
sqlx::query(
|
||||
r#"
|
||||
|
||||
with_transaction(&self.pool, "update_user", |tx| {
|
||||
Box::pin(async move {
|
||||
// Update the user
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE auth.users
|
||||
SET
|
||||
username = $2,
|
||||
@@ -262,35 +250,39 @@ impl UserRepository for UserPgRepository {
|
||||
last_login_at = $9,
|
||||
active = $10
|
||||
WHERE id = $1
|
||||
"#
|
||||
)
|
||||
.bind(user_clone.id())
|
||||
.bind(user_clone.username())
|
||||
.bind(user_clone.email())
|
||||
.bind(user_clone.password_hash())
|
||||
.bind(user_clone.role().to_string())
|
||||
.bind(user_clone.storage_quota_bytes())
|
||||
.bind(user_clone.storage_used_bytes())
|
||||
.bind(user_clone.updated_at())
|
||||
.bind(user_clone.last_login_at())
|
||||
.bind(user_clone.is_active())
|
||||
.execute(&mut **tx)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
// We could perform additional operations here inside
|
||||
// the same transaction, such as updating permissions, etc.
|
||||
|
||||
Ok(user_clone)
|
||||
}) as BoxFuture<'_, UserRepositoryResult<User>>
|
||||
}
|
||||
).await?;
|
||||
|
||||
"#,
|
||||
)
|
||||
.bind(user_clone.id())
|
||||
.bind(user_clone.username())
|
||||
.bind(user_clone.email())
|
||||
.bind(user_clone.password_hash())
|
||||
.bind(user_clone.role().to_string())
|
||||
.bind(user_clone.storage_quota_bytes())
|
||||
.bind(user_clone.storage_used_bytes())
|
||||
.bind(user_clone.updated_at())
|
||||
.bind(user_clone.last_login_at())
|
||||
.bind(user_clone.is_active())
|
||||
.execute(&mut **tx)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
// We could perform additional operations here inside
|
||||
// the same transaction, such as updating permissions, etc.
|
||||
|
||||
Ok(user_clone)
|
||||
}) as BoxFuture<'_, UserRepositoryResult<User>>
|
||||
})
|
||||
.await?;
|
||||
|
||||
Ok(user)
|
||||
}
|
||||
|
||||
|
||||
/// Updates only the storage usage of a user
|
||||
async fn update_storage_usage(&self, user_id: &str, usage_bytes: i64) -> UserRepositoryResult<()> {
|
||||
async fn update_storage_usage(
|
||||
&self,
|
||||
user_id: &str,
|
||||
usage_bytes: i64,
|
||||
) -> UserRepositoryResult<()> {
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE auth.users
|
||||
@@ -298,7 +290,7 @@ impl UserRepository for UserPgRepository {
|
||||
storage_used_bytes = $2,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(usage_bytes)
|
||||
@@ -308,7 +300,7 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Updates the last login date
|
||||
async fn update_last_login(&self, user_id: &str) -> UserRepositoryResult<()> {
|
||||
sqlx::query(
|
||||
@@ -318,7 +310,7 @@ impl UserRepository for UserPgRepository {
|
||||
last_login_at = NOW(),
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.execute(&*self.pool)
|
||||
@@ -327,7 +319,7 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Lists users with pagination
|
||||
async fn list_users(&self, limit: i64, offset: i64) -> UserRepositoryResult<Vec<User>> {
|
||||
let rows = sqlx::query(
|
||||
@@ -340,7 +332,7 @@ impl UserRepository for UserPgRepository {
|
||||
FROM auth.users
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $1 OFFSET $2
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(limit)
|
||||
.bind(offset)
|
||||
@@ -348,7 +340,8 @@ impl UserRepository for UserPgRepository {
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
let users = rows.into_iter()
|
||||
let users = rows
|
||||
.into_iter()
|
||||
.map(|row| {
|
||||
// Convert role string to UserRole enum for each row
|
||||
let role_str: Option<String> = row.try_get("role_text").unwrap_or(None);
|
||||
@@ -356,7 +349,7 @@ impl UserRepository for UserPgRepository {
|
||||
Some("admin") => UserRole::Admin,
|
||||
_ => UserRole::User,
|
||||
};
|
||||
|
||||
|
||||
User::from_data_full(
|
||||
row.get("id"),
|
||||
row.get("username"),
|
||||
@@ -377,9 +370,13 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(users)
|
||||
}
|
||||
|
||||
|
||||
/// Activates or deactivates a user
|
||||
async fn set_user_active_status(&self, user_id: &str, active: bool) -> UserRepositoryResult<()> {
|
||||
async fn set_user_active_status(
|
||||
&self,
|
||||
user_id: &str,
|
||||
active: bool,
|
||||
) -> UserRepositoryResult<()> {
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE auth.users
|
||||
@@ -387,7 +384,7 @@ impl UserRepository for UserPgRepository {
|
||||
active = $2,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(active)
|
||||
@@ -397,9 +394,13 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Changes a user's password
|
||||
async fn change_password(&self, user_id: &str, password_hash: &str) -> UserRepositoryResult<()> {
|
||||
async fn change_password(
|
||||
&self,
|
||||
user_id: &str,
|
||||
password_hash: &str,
|
||||
) -> UserRepositoryResult<()> {
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE auth.users
|
||||
@@ -407,7 +408,7 @@ impl UserRepository for UserPgRepository {
|
||||
password_hash = $2,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(password_hash)
|
||||
@@ -417,12 +418,12 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Changes a user's role
|
||||
async fn change_role(&self, user_id: &str, role: UserRole) -> UserRepositoryResult<()> {
|
||||
// Convert the role to string for the binding
|
||||
let role_str = role.to_string();
|
||||
|
||||
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE auth.users
|
||||
@@ -430,7 +431,7 @@ impl UserRepository for UserPgRepository {
|
||||
role = $2::auth.userrole,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(&role_str)
|
||||
@@ -440,7 +441,7 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
/// Lists users by role
|
||||
async fn list_users_by_role(&self, role: &str) -> UserRepositoryResult<Vec<User>> {
|
||||
let rows = sqlx::query(
|
||||
@@ -453,14 +454,15 @@ impl UserRepository for UserPgRepository {
|
||||
FROM auth.users
|
||||
WHERE role::text = $1
|
||||
ORDER BY created_at DESC
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(role)
|
||||
.fetch_all(&*self.pool)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
let users = rows.into_iter()
|
||||
let users = rows
|
||||
.into_iter()
|
||||
.map(|row| {
|
||||
// Convert role string to UserRole enum for each row
|
||||
let role_str: Option<String> = row.try_get("role_text").unwrap_or(None);
|
||||
@@ -468,7 +470,7 @@ impl UserRepository for UserPgRepository {
|
||||
Some("admin") => UserRole::Admin,
|
||||
_ => UserRole::User,
|
||||
};
|
||||
|
||||
|
||||
User::from_data_full(
|
||||
row.get("id"),
|
||||
row.get("username"),
|
||||
@@ -489,14 +491,14 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
Ok(users)
|
||||
}
|
||||
|
||||
|
||||
/// Deletes a user
|
||||
async fn delete_user(&self, user_id: &str) -> UserRepositoryResult<()> {
|
||||
sqlx::query(
|
||||
r#"
|
||||
DELETE FROM auth.users
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.execute(&*self.pool)
|
||||
@@ -507,7 +509,11 @@ impl UserRepository for UserPgRepository {
|
||||
}
|
||||
|
||||
/// Finds a user by OIDC provider + subject pair
|
||||
async fn get_user_by_oidc_subject(&self, provider: &str, subject: &str) -> UserRepositoryResult<User> {
|
||||
async fn get_user_by_oidc_subject(
|
||||
&self,
|
||||
provider: &str,
|
||||
subject: &str,
|
||||
) -> UserRepositoryResult<User> {
|
||||
let row = sqlx::query(
|
||||
r#"
|
||||
SELECT
|
||||
@@ -517,7 +523,7 @@ impl UserRepository for UserPgRepository {
|
||||
oidc_provider, oidc_subject
|
||||
FROM auth.users
|
||||
WHERE oidc_provider = $1 AND oidc_subject = $2
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(provider)
|
||||
.bind(subject)
|
||||
@@ -549,7 +555,11 @@ impl UserRepository for UserPgRepository {
|
||||
}
|
||||
|
||||
/// Updates a user's storage quota
|
||||
async fn update_storage_quota(&self, user_id: &str, quota_bytes: i64) -> UserRepositoryResult<()> {
|
||||
async fn update_storage_quota(
|
||||
&self,
|
||||
user_id: &str,
|
||||
quota_bytes: i64,
|
||||
) -> UserRepositoryResult<()> {
|
||||
sqlx::query(
|
||||
r#"
|
||||
UPDATE auth.users
|
||||
@@ -557,7 +567,7 @@ impl UserRepository for UserPgRepository {
|
||||
storage_quota_bytes = $2,
|
||||
updated_at = NOW()
|
||||
WHERE id = $1
|
||||
"#
|
||||
"#,
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(quota_bytes)
|
||||
@@ -570,12 +580,10 @@ impl UserRepository for UserPgRepository {
|
||||
|
||||
/// Counts the total number of users
|
||||
async fn count_users(&self) -> UserRepositoryResult<i64> {
|
||||
let row = sqlx::query(
|
||||
"SELECT COUNT(*) as count FROM auth.users"
|
||||
)
|
||||
.fetch_one(&*self.pool)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
let row = sqlx::query("SELECT COUNT(*) as count FROM auth.users")
|
||||
.fetch_one(&*self.pool)
|
||||
.await
|
||||
.map_err(Self::map_sqlx_error)?;
|
||||
|
||||
let count: i64 = row.get("count");
|
||||
Ok(count)
|
||||
@@ -614,52 +622,74 @@ impl UserRepository for UserPgRepository {
|
||||
#[async_trait]
|
||||
impl UserStoragePort for UserPgRepository {
|
||||
async fn create_user(&self, user: User) -> Result<User, DomainError> {
|
||||
UserRepository::create_user(self, user).await.map_err(DomainError::from)
|
||||
UserRepository::create_user(self, user)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn get_user_by_id(&self, id: &str) -> Result<User, DomainError> {
|
||||
UserRepository::get_user_by_id(self, id).await.map_err(DomainError::from)
|
||||
UserRepository::get_user_by_id(self, id)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn get_user_by_username(&self, username: &str) -> Result<User, DomainError> {
|
||||
UserRepository::get_user_by_username(self, username).await.map_err(DomainError::from)
|
||||
UserRepository::get_user_by_username(self, username)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn get_user_by_email(&self, email: &str) -> Result<User, DomainError> {
|
||||
UserRepository::get_user_by_email(self, email).await.map_err(DomainError::from)
|
||||
UserRepository::get_user_by_email(self, email)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn update_user(&self, user: User) -> Result<User, DomainError> {
|
||||
UserRepository::update_user(self, user).await.map_err(DomainError::from)
|
||||
UserRepository::update_user(self, user)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
async fn update_storage_usage(&self, user_id: &str, usage_bytes: i64) -> Result<(), DomainError> {
|
||||
|
||||
async fn update_storage_usage(
|
||||
&self,
|
||||
user_id: &str,
|
||||
usage_bytes: i64,
|
||||
) -> Result<(), DomainError> {
|
||||
UserRepository::update_storage_usage(self, user_id, usage_bytes)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn list_users(&self, limit: i64, offset: i64) -> Result<Vec<User>, DomainError> {
|
||||
UserRepository::list_users(self, limit, offset).await.map_err(DomainError::from)
|
||||
UserRepository::list_users(self, limit, offset)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn list_users_by_role(&self, role: &str) -> Result<Vec<User>, DomainError> {
|
||||
UserRepository::list_users_by_role(self, role).await.map_err(DomainError::from)
|
||||
UserRepository::list_users_by_role(self, role)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn delete_user(&self, user_id: &str) -> Result<(), DomainError> {
|
||||
UserRepository::delete_user(self, user_id)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
|
||||
async fn change_password(&self, user_id: &str, password_hash: &str) -> Result<(), DomainError> {
|
||||
UserRepository::change_password(self, user_id, password_hash)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
async fn get_user_by_oidc_subject(&self, provider: &str, subject: &str) -> Result<User, DomainError> {
|
||||
async fn get_user_by_oidc_subject(
|
||||
&self,
|
||||
provider: &str,
|
||||
subject: &str,
|
||||
) -> Result<User, DomainError> {
|
||||
UserRepository::get_user_by_oidc_subject(self, provider, subject)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
@@ -681,7 +711,11 @@ impl UserStoragePort for UserPgRepository {
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
|
||||
async fn update_storage_quota(&self, user_id: &str, quota_bytes: i64) -> Result<(), DomainError> {
|
||||
async fn update_storage_quota(
|
||||
&self,
|
||||
user_id: &str,
|
||||
quota_bytes: i64,
|
||||
) -> Result<(), DomainError> {
|
||||
UserRepository::update_storage_quota(self, user_id, quota_bytes)
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
@@ -692,4 +726,4 @@ impl UserStoragePort for UserPgRepository {
|
||||
.await
|
||||
.map_err(DomainError::from)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user