1use crate::{
2 models::{Bot, Permissions},
3 Maybe,
4};
5use serde::{Deserialize, Serialize};
6#[cfg(feature = "utoipa")]
7use utoipa::ToSchema;
8
9#[derive(Clone, Debug, Deserialize)]
11#[cfg_attr(feature = "client", derive(Serialize))]
12#[cfg_attr(feature = "utoipa", derive(ToSchema))]
13pub struct CreateUserPayload {
14 pub username: String,
17 pub display_name: Option<String>,
19 #[cfg_attr(feature = "utoipa", schema(format = "email"))]
21 pub email: String,
22 #[cfg_attr(feature = "utoipa", schema(format = "password"))]
24 pub password: String,
25 pub captcha_token: String,
27}
28
29#[derive(Clone, Debug, Serialize)]
31#[cfg_attr(feature = "client", derive(Deserialize))]
32#[cfg_attr(feature = "utoipa", derive(ToSchema))]
33pub struct CreateUserResponse {
34 pub id: u64,
36 pub token: String,
38}
39
40#[derive(Clone, Debug, Deserialize)]
42#[cfg_attr(feature = "client", derive(Serialize))]
43#[cfg_attr(feature = "utoipa", derive(ToSchema))]
44pub struct DeleteUserPayload {
45 #[cfg_attr(feature = "utoipa", schema(format = "password"))]
47 pub password: String,
48}
49
50#[derive(Clone, Debug, Deserialize)]
52#[cfg_attr(feature = "client", derive(Serialize))]
53#[cfg_attr(feature = "utoipa", derive(ToSchema))]
54pub struct ChangePasswordPayload {
55 pub current_password: String,
57 pub new_password: String,
59}
60
61#[derive(Clone, Debug, Deserialize)]
63#[cfg_attr(feature = "client", derive(Serialize))]
64#[cfg_attr(feature = "utoipa", derive(ToSchema))]
65pub struct ChangeEmailPayload {
66 pub password: String,
68 pub new_email: String,
70}
71
72#[derive(Clone, Debug, Deserialize)]
74#[cfg_attr(feature = "client", derive(Serialize))]
75#[cfg_attr(feature = "utoipa", derive(ToSchema))]
76pub struct EditUserPayload {
77 pub username: Option<String>,
79 #[serde(default)]
82 #[cfg_attr(feature = "client", serde(skip_serializing_if = "Maybe::is_absent"))]
83 #[cfg_attr(feature = "utoipa", schema(nullable, value_type = Option<String>))]
84 pub display_name: Maybe<String>,
85 #[serde(default)]
89 #[cfg_attr(feature = "client", serde(skip_serializing_if = "Maybe::is_absent"))]
90 #[cfg_attr(feature = "utoipa", schema(nullable, value_type = Option<String>, format = Byte))]
91 pub avatar: Maybe<String>,
92 #[serde(default)]
95 #[cfg_attr(feature = "client", serde(skip_serializing_if = "Maybe::is_absent"))]
96 #[cfg_attr(feature = "utoipa", schema(nullable, value_type = Option<String>))]
97 pub banner: Maybe<String>,
98 #[serde(default)]
101 #[cfg_attr(feature = "client", serde(skip_serializing_if = "Maybe::is_absent"))]
102 #[cfg_attr(feature = "utoipa", schema(nullable, value_type = Option<String>))]
103 pub bio: Maybe<String>,
104}
105
106#[derive(Clone, Debug, Deserialize)]
108#[cfg_attr(feature = "client", derive(Serialize))]
109#[cfg_attr(feature = "utoipa", derive(ToSchema))]
110pub struct SendFriendRequestPayload {
111 pub username: String,
113}
114
115#[derive(Clone, Debug, Deserialize)]
117#[cfg_attr(feature = "client", derive(Serialize))]
118#[cfg_attr(feature = "utoipa", derive(ToSchema))]
119pub struct CreateBotPayload {
120 pub username: String,
126 pub display_name: Option<String>,
128 #[serde(default)]
131 pub public: bool,
132}
133
134#[derive(Clone, Debug, Serialize)]
136#[cfg_attr(feature = "client", derive(Deserialize))]
137#[cfg_attr(feature = "utoipa", derive(ToSchema))]
138pub struct CreateBotResponse {
139 #[serde(flatten)]
141 pub bot: Bot,
142 pub token: String,
144}
145
146#[derive(Clone, Debug, Deserialize)]
148#[cfg_attr(feature = "client", derive(Serialize))]
149#[cfg_attr(feature = "utoipa", derive(ToSchema))]
150pub struct EditBotPayload {
151 #[serde(flatten)]
153 pub user_payload: EditUserPayload,
154 pub public: Option<bool>,
156 pub default_permissions: Option<Permissions>,
159 pub guild_enabled: Option<bool>,
161 pub group_dm_enabled: Option<bool>,
163 pub global_enabled: Option<bool>,
165}
166
167#[derive(Clone, Debug, Deserialize)]
169#[cfg_attr(feature = "client", derive(Serialize))]
170#[cfg_attr(feature = "utoipa", derive(ToSchema))]
171pub struct DeleteBotPayload {
172 #[cfg_attr(feature = "utoipa", schema(format = "password"))]
174 pub password: String,
175}
176
177#[derive(Clone, Debug, Deserialize)]
179#[cfg_attr(feature = "client", derive(Serialize))]
180#[cfg_attr(feature = "utoipa", derive(ToSchema))]
181pub struct RegenerateBotTokenPayload {
182 #[cfg_attr(feature = "utoipa", schema(format = "password"))]
184 pub password: String,
185}