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, pub bio: Option, pub email_verified: bool, } #[derive(Deserialize, Serialize, Debug)] pub struct AuthTokenSchema { pub user_id: Uuid, pub kind: AuthTokenKind, pub expires_at: chrono::DateTime, } #[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, pub avatar_url: Option, } #[derive(Deserialize, Serialize, Debug)] pub struct WorkspaceInvitationSchema { pub workspace_id: Uuid, pub created_by: Uuid, pub max_uses: Option, pub expires_at: Option>, } #[derive(Deserialize, Serialize, Debug)] pub struct ConversationSchema { pub workspace_id: Option, pub kind: ConversationKind, pub name: Option, 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 { /// Supplied by the client, not the server. Without it the client cannot /// reconcile its optimistically rendered message with the one that comes /// back over the realtime channel — it would show up twice. Bonus: sending /// becomes idempotent, so a retry after an unclear network error is a no-op /// instead of a duplicate. pub id: Uuid, 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, }