refactor(quark): port ban_create, ban_list, ban_remove, emoji_list, invites_fetch

#283
This commit is contained in:
Paul Makles
2024-04-07 20:48:36 +01:00
parent b2d3344ddd
commit 03340a2b5a
11 changed files with 250 additions and 189 deletions

View File

@@ -1,4 +1,7 @@
use super::MemberCompositeKey;
use super::{File, MemberCompositeKey, User};
#[cfg(feature = "validator")]
use validator::Validate;
auto_derived!(
/// Server Ban
@@ -9,4 +12,44 @@ auto_derived!(
/// Reason for ban creation
pub reason: Option<String>,
}
/// Information for new server ban
#[cfg_attr(feature = "validator", derive(Validate))]
pub struct DataBanCreate {
/// Ban reason
#[cfg_attr(feature = "validator", validate(length(min = 0, max = 1024)))]
pub reason: Option<String>,
}
/// Just enough information to list a ban
pub struct BannedUser {
/// Id of the banned user
#[cfg_attr(feature = "serde", serde(rename = "_id"))]
pub id: String,
/// Username of the banned user
pub username: String,
/// Discriminator of the banned user
pub discriminator: String,
/// Avatar of the banned user
pub avatar: Option<File>,
}
/// Ban list result
pub struct BanListResult {
/// Users objects
pub users: Vec<BannedUser>,
/// Ban objects
pub bans: Vec<ServerBan>,
}
);
impl From<User> for BannedUser {
fn from(user: User) -> Self {
BannedUser {
id: user.id,
username: user.username,
discriminator: user.discriminator,
avatar: user.avatar,
}
}
}