cloudreve_api/api/v4/models/
user.rs

1//! User management models for Cloudreve API v4
2
3use serde::{Deserialize, Serialize};
4
5/// Storage quota information
6#[derive(Debug, Deserialize)]
7pub struct Quota {
8    pub used: u64,
9    pub total: u64,
10    #[serde(default)]
11    pub storage_pack_total: Option<u64>,
12}
13
14/// User settings (preferences)
15#[derive(Debug, Serialize, Deserialize, Default)]
16#[serde(default)]
17pub struct UserSettings {
18    /// Group expiration date
19    #[serde(default)]
20    pub group_expires: Option<String>,
21
22    /// Linked OpenID providers
23    #[serde(default)]
24    pub open_id: Option<Vec<OpenIDInfo>>,
25
26    /// Whether file version retention is enabled
27    #[serde(default)]
28    pub version_retention_enabled: bool,
29
30    /// File extensions with version retention enabled
31    #[serde(default)]
32    pub version_retention_ext: Option<Vec<String>>,
33
34    /// Max preserved versions (0 = all)
35    #[serde(default)]
36    pub version_retention_max: Option<i64>,
37
38    /// Whether account is passwordless
39    #[serde(default)]
40    pub passwordless: bool,
41
42    /// Whether 2FA is enabled
43    #[serde(default)]
44    pub two_fa_enabled: bool,
45
46    /// Registered passkeys
47    #[serde(default)]
48    pub passkeys: Option<Vec<Passkey>>,
49
50    /// Recent login activities
51    #[serde(default)]
52    pub login_activity: Option<Vec<LoginActivity>>,
53
54    /// Storage packs
55    #[serde(default)]
56    pub storage_packs: Vec<StoragePack>,
57
58    /// Available credit/points
59    #[serde(default)]
60    pub credit: i64,
61
62    /// Whether view sync is disabled
63    #[serde(default)]
64    pub disable_view_sync: bool,
65
66    /// Share link visibility in profile
67    #[serde(default)]
68    pub share_links_in_profile: Option<String>,
69}
70
71/// OpenID provider information
72#[derive(Debug, Serialize, Deserialize, Default)]
73#[serde(default)]
74pub struct OpenIDInfo {
75    #[serde(default)]
76    pub provider: i32,
77    #[serde(default)]
78    pub linked_at: String,
79}
80
81/// Passkey information
82#[derive(Debug, Serialize, Deserialize, Default)]
83#[serde(default)]
84pub struct Passkey {
85    #[serde(default)]
86    pub id: String,
87    #[serde(default)]
88    pub name: String,
89    #[serde(default)]
90    pub used_at: Option<String>,
91    #[serde(default)]
92    pub created_at: String,
93}
94
95/// Login activity record
96#[derive(Debug, Serialize, Deserialize, Default)]
97#[serde(default)]
98pub struct LoginActivity {
99    #[serde(default)]
100    pub created_at: String,
101    #[serde(default)]
102    pub ip: String,
103    #[serde(default)]
104    pub browser: String,
105    #[serde(default)]
106    pub device: String,
107    #[serde(default)]
108    pub os: String,
109    #[serde(default)]
110    pub login_with: String,
111    #[serde(default)]
112    pub open_id_provider: i32,
113    #[serde(default)]
114    pub success: bool,
115    #[serde(default)]
116    pub webdav: bool,
117}
118
119/// Storage pack information
120#[derive(Debug, Serialize, Deserialize, Default)]
121#[serde(default)]
122pub struct StoragePack {
123    #[serde(default)]
124    pub name: String,
125    #[serde(default)]
126    pub active_since: String,
127    #[serde(default)]
128    pub expire_at: String,
129    #[serde(default)]
130    pub size: i64,
131}
132
133/// Update profile request
134#[derive(Debug, Serialize)]
135pub struct UpdateProfileRequest<'a> {
136    pub nickname: Option<&'a str>,
137    pub email: Option<&'a str>,
138    pub avatar: Option<&'a str>,
139}
140
141/// Change password request
142#[derive(Debug, Serialize)]
143pub struct ChangePasswordRequest<'a> {
144    pub old_password: &'a str,
145    pub new_password: &'a str,
146}
147
148/// Search user request
149#[derive(Debug, Serialize)]
150pub struct SearchUserRequest<'a> {
151    pub query: &'a str,
152    pub page: Option<u32>,
153    pub page_size: Option<u32>,
154}
155
156/// Update user setting request
157#[derive(Debug, Serialize)]
158pub struct UpdateUserSettingRequest<'a> {
159    pub key: &'a str,
160    pub value: &'a str,
161}
162
163/// Credit change record
164#[derive(Debug, Serialize, Deserialize)]
165pub struct CreditChangeRecord {
166    pub id: String,
167    pub amount: i64,
168    pub reason: String,
169    pub created_at: String,
170}
171
172/// Payment record
173#[derive(Debug, Serialize, Deserialize)]
174pub struct PaymentRecord {
175    pub id: String,
176    pub amount: f64,
177    pub method: String,
178    pub status: String,
179    pub created_at: String,
180    pub transaction_id: Option<String>,
181}