feat(delta): rewrite emoji routes w/o quark

#283
This commit is contained in:
Paul Makles
2023-09-05 12:36:18 +01:00
parent 895de86f1e
commit 9789909061
9 changed files with 101 additions and 91 deletions

View File

@@ -1,3 +1,12 @@
use once_cell::sync::Lazy;
use regex::Regex;
use validator::Validate;
/// Regex for valid emoji names
///
/// Alphanumeric and underscores
pub static RE_EMOJI: Lazy<Regex> = Lazy::new(|| Regex::new(r"^[a-z0-9_]+$").unwrap());
auto_derived!(
/// Emoji
pub struct Emoji {
@@ -30,4 +39,17 @@ auto_derived!(
Server { id: String },
Detached,
}
/// Create a new emoji
#[derive(Validate)]
pub struct DataCreateEmoji {
/// Server name
#[validate(length(min = 1, max = 32), regex = "RE_EMOJI")]
pub name: String,
/// Parent information
pub parent: EmojiParent,
/// Whether the emoji is mature
#[serde(default)]
pub nsfw: bool,
}
);