forked from jmug/stoatchat
chore: migrate bots create route
This commit is contained in:
@@ -20,8 +20,12 @@ default = ["serde", "partials"]
|
||||
# Core
|
||||
revolt-permissions = { version = "0.6.5", path = "../permissions" }
|
||||
|
||||
# Serialisation
|
||||
# Utility
|
||||
regex = "1"
|
||||
indexmap = "1.9.3"
|
||||
once_cell = "1.17.1"
|
||||
|
||||
# Serialisation
|
||||
revolt_optional_struct = { version = "0.2.0", optional = true }
|
||||
serde = { version = "1", features = ["derive"], optional = true }
|
||||
iso8601-timestamp = { version = "0.2.11", features = ["schema", "bson"] }
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use super::User;
|
||||
|
||||
use validator::Validate;
|
||||
|
||||
auto_derived!(
|
||||
/// Bot
|
||||
#[derive(Default)]
|
||||
pub struct Bot {
|
||||
/// Bot Id
|
||||
#[cfg_attr(feature = "serde", serde(rename = "_id"))]
|
||||
@@ -87,12 +90,13 @@ auto_derived!(
|
||||
}
|
||||
|
||||
/// Bot Details
|
||||
#[cfg_attr(feature = "validator", derive(Validate))]
|
||||
pub struct DataCreateBot {
|
||||
/// Bot username
|
||||
#[cfg_attr(
|
||||
feature = "validator",
|
||||
validate(length(min = 2, max = 32), regex = "RE_USERNAME")
|
||||
validate(length(min = 2, max = 32), regex = "super::RE_USERNAME")
|
||||
)]
|
||||
name: String,
|
||||
pub name: String,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
use once_cell::sync::Lazy;
|
||||
use regex::Regex;
|
||||
|
||||
use super::File;
|
||||
|
||||
/// Regex for valid usernames
|
||||
///
|
||||
/// Block zero width space
|
||||
/// Block lookalike characters
|
||||
pub static RE_USERNAME: Lazy<Regex> = Lazy::new(|| Regex::new(r"^(\p{L}|[\d_.-])+$").unwrap());
|
||||
|
||||
auto_derived!(
|
||||
/// User
|
||||
pub struct User {
|
||||
|
||||
Reference in New Issue
Block a user