feat: add user roles and storage quota management
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
#[derive(Debug, Clone, PartialEq, Eq, sqlx::Type)]
|
||||
#[sqlx(rename_all = "lowercase")]
|
||||
#[sqlx(type_name = "TEXT")]
|
||||
pub enum Role {
|
||||
User,
|
||||
Admin,
|
||||
}
|
||||
|
||||
impl Role {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
Role::User => "user",
|
||||
Role::Admin => "admin",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Media {
|
||||
pub id: uuid::Uuid,
|
||||
pub owner_id: uuid::Uuid,
|
||||
@@ -11,7 +28,7 @@ pub struct Media {
|
||||
pub height: Option<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, sqlx::FromRow)]
|
||||
pub struct User {
|
||||
pub id: uuid::Uuid,
|
||||
pub username: String,
|
||||
@@ -19,6 +36,10 @@ pub struct User {
|
||||
pub hashed_password: String,
|
||||
pub created_at: chrono::DateTime<chrono::Utc>,
|
||||
pub updated_at: chrono::DateTime<chrono::Utc>,
|
||||
|
||||
pub role: Role,
|
||||
pub storage_quota: i64, // in bytes
|
||||
pub storage_used: i64, // in bytes
|
||||
}
|
||||
|
||||
pub struct Album {
|
||||
|
||||
Reference in New Issue
Block a user