use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; // Auth #[derive(Debug, Deserialize)] pub struct LoginRequest { pub username: String, pub password: String, } #[derive(Debug, Serialize)] pub struct LoginResponse { pub token: String, pub username: String, pub role: String, } #[derive(Debug, Serialize)] pub struct UserInfoResponse { pub username: String, pub role: String, } // Users #[derive(Debug, Serialize)] pub struct UserResponse { pub id: String, pub username: String, pub role: String, pub profile: UserProfileResponse, pub created_at: DateTime, pub updated_at: DateTime, } #[derive(Debug, Serialize)] pub struct UserProfileResponse { pub avatar_path: Option, pub bio: Option, pub preferences: UserPreferencesResponse, } #[derive(Debug, Serialize)] pub struct UserPreferencesResponse { pub theme: Option, pub language: Option, pub default_video_quality: Option, pub auto_play: bool, } #[derive(Debug, Serialize)] pub struct UserLibraryResponse { pub user_id: String, pub root_path: String, pub permission: String, pub granted_at: DateTime, } #[derive(Debug, Deserialize)] pub struct GrantLibraryAccessRequest { pub root_path: String, pub permission: pinakes_core::users::LibraryPermission, } #[derive(Debug, Deserialize)] pub struct RevokeLibraryAccessRequest { pub root_path: String, } impl From for UserResponse { fn from(user: pinakes_core::users::User) -> Self { Self { id: user.id.0.to_string(), username: user.username, role: user.role.to_string(), profile: UserProfileResponse { avatar_path: user.profile.avatar_path, bio: user.profile.bio, preferences: UserPreferencesResponse { theme: user.profile.preferences.theme, language: user.profile.preferences.language, default_video_quality: user.profile.preferences.default_video_quality, auto_play: user.profile.preferences.auto_play, }, }, created_at: user.created_at, updated_at: user.updated_at, } } } impl From for UserLibraryResponse { fn from(access: pinakes_core::users::UserLibraryAccess) -> Self { Self { user_id: access.user_id.0.to_string(), root_path: access.root_path, permission: access.permission.to_string(), granted_at: access.granted_at, } } }