feat: initial commit
Axum/Postgres server with auth, migrations, and Docker setup.
This commit is contained in:
103
src/schema.rs
Normal file
103
src/schema.rs
Normal file
@@ -0,0 +1,103 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::model::{AuthTokenKind, ConversationKind, WorkspaceRole};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RegisterSchema {
|
||||
pub email: String,
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct LoginSchema {
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub struct RefreshSchema {
|
||||
pub refresh_token: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct UserSchema {
|
||||
pub email: String,
|
||||
pub password_hash: String,
|
||||
pub username: String,
|
||||
pub display_name: String,
|
||||
pub avatar_url: Option<String>,
|
||||
pub bio: Option<String>,
|
||||
pub email_verified: bool,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct AuthTokenSchema {
|
||||
pub user_id: Uuid,
|
||||
pub kind: AuthTokenKind,
|
||||
pub expires_at: chrono::DateTime<chrono::Utc>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct WorkspaceSchema {
|
||||
pub name: String,
|
||||
pub slug: String,
|
||||
pub owner_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct WorkspaceMemberSchema {
|
||||
pub workspace_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub role: WorkspaceRole,
|
||||
pub display_name: Option<String>,
|
||||
pub avatar_url: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct WorkspaceInvitationSchema {
|
||||
pub workspace_id: Uuid,
|
||||
pub created_by: Uuid,
|
||||
pub max_uses: Option<i32>,
|
||||
pub expires_at: Option<chrono::DateTime<chrono::Utc>>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct ConversationSchema {
|
||||
pub workspace_id: Option<Uuid>,
|
||||
pub kind: ConversationKind,
|
||||
pub name: Option<String>,
|
||||
pub is_public: bool,
|
||||
pub created_by: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct ConversationMemberSchema {
|
||||
pub conversation_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct MessageSchema {
|
||||
pub conversation_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub content: String,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct AttachmentSchema {
|
||||
pub message_id: Uuid,
|
||||
pub url: String,
|
||||
pub filename: String,
|
||||
pub mime_type: String,
|
||||
pub size_bytes: i64,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
pub struct ReactionSchema {
|
||||
pub message_id: Uuid,
|
||||
pub user_id: Uuid,
|
||||
pub emoji: String,
|
||||
}
|
||||
Reference in New Issue
Block a user