chore(core): flesh out implementations for channels / servers

This commit is contained in:
Paul Makles
2023-08-03 18:27:13 +01:00
parent bd9ecc1519
commit d87d608d9e
6 changed files with 193 additions and 37 deletions

View File

@@ -2,7 +2,7 @@ use super::File;
use iso8601_timestamp::Timestamp;
auto_derived!(
auto_derived_partial!(
/// Server Member
pub struct Member {
/// Unique member id
@@ -29,8 +29,11 @@ auto_derived!(
/// Timestamp this member is timed out until
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))]
pub timeout: Option<Timestamp>,
}
},
"PartialMember"
);
auto_derived!(
/// Composite primary key consisting of server and user id
#[derive(Hash, Default)]
pub struct MemberCompositeKey {
@@ -39,4 +42,19 @@ auto_derived!(
/// User Id
pub user: String,
}
/// Optional fields on server member object
pub enum FieldsMember {
Nickname,
Avatar,
Roles,
Timeout,
}
/// Member removal intention
pub enum RemovalIntention {
Leave,
Kick,
Ban,
}
);

View File

@@ -3,7 +3,7 @@ use super::File;
use revolt_permissions::OverrideField;
use std::collections::HashMap;
auto_derived!(
auto_derived_partial!(
/// Server
pub struct Server {
/// Unique Id
@@ -72,18 +72,11 @@ auto_derived!(
serde(skip_serializing_if = "crate::if_false", default)
)]
pub discoverable: bool,
}
/// Channel category
pub struct Category {
/// Unique ID for this category
pub id: String,
/// Title for this category
pub title: String,
/// Channels in this category
pub channels: Vec<String>,
}
},
"PartialServer"
);
auto_derived_partial!(
/// Role
pub struct Role {
/// Role name
@@ -104,6 +97,33 @@ auto_derived!(
/// Ranking of this role
#[cfg_attr(feature = "serde", serde(default))]
pub rank: i64,
},
"PartialRole"
);
auto_derived!(
/// Optional fields on server object
pub enum FieldsServer {
Description,
Categories,
SystemMessages,
Icon,
Banner,
}
/// Optional fields on server object
pub enum FieldsRole {
Colour,
}
/// Channel category
pub struct Category {
/// Unique ID for this category
pub id: String,
/// Title for this category
pub title: String,
/// Channels in this category
pub channels: Vec<String>,
}
/// System message channel assignments