refactor: implement Server::create

This commit is contained in:
Paul Makles
2023-10-28 14:25:29 +01:00
parent cd0737911b
commit a6bc9fcbb3
7 changed files with 134 additions and 197 deletions

View File

@@ -1,8 +1,11 @@
use super::File;
use super::{Channel, File};
use revolt_permissions::OverrideField;
use std::collections::HashMap;
#[cfg(feature = "validator")]
use validator::Validate;
auto_derived_partial!(
/// Server
pub struct Server {
@@ -141,4 +144,27 @@ auto_derived!(
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub user_banned: Option<String>,
}
/// Information about new server to create
#[derive(Default)]
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct DataCreateServer {
/// Server name
#[cfg_attr(feature = "validator", validate(length(min = 1, max = 32)))]
pub name: String,
/// Server description
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 1024)))]
pub description: Option<String>,
/// Whether this server is age-restricted
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub nsfw: Option<bool>,
}
/// Information returned when creating server
pub struct CreateServerLegacyResponse {
/// Server object
pub server: Server,
/// Default channels
pub channels: Vec<Channel>,
}
);