-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core/models): implement server members model
closes #280
- Loading branch information
Showing
5 changed files
with
78 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,18 @@ name = "revolt-models" | |
version = "0.6.5" | ||
edition = "2021" | ||
license = "AGPL-3.0-or-later" | ||
authors = [ "Paul Makles <[email protected]>" ] | ||
authors = ["Paul Makles <[email protected]>"] | ||
description = "Revolt Backend: API Models" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[features] | ||
serde = [ "dep:serde", "revolt-permissions/serde" ] | ||
schemas = [ "dep:schemars", "revolt-permissions/schemas" ] | ||
validator = [ "dep:validator" ] | ||
partials = [ "dep:revolt_optional_struct", "serde", "schemas" ] | ||
serde = ["dep:serde", "revolt-permissions/serde"] | ||
schemas = ["dep:schemars", "revolt-permissions/schemas"] | ||
validator = ["dep:validator"] | ||
partials = ["dep:revolt_optional_struct", "serde", "schemas"] | ||
|
||
default = [ "serde", "partials" ] | ||
default = ["serde", "partials"] | ||
|
||
[dependencies] | ||
# Core | ||
|
@@ -23,6 +23,7 @@ revolt-permissions = { version = "0.6.5", path = "../permissions" } | |
# 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"] } | ||
|
||
# Spec Generation | ||
schemars = { version = "0.8.8", optional = true } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use super::File; | ||
|
||
use iso8601_timestamp::Timestamp; | ||
|
||
auto_derived!( | ||
/// Server Member | ||
pub struct Member { | ||
/// Unique member id | ||
#[cfg_attr(feature = "serde", serde(rename = "_id"))] | ||
pub id: MemberCompositeKey, | ||
|
||
/// Time at which this user joined the server | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub joined_at: Option<Timestamp>, | ||
|
||
/// Member's nickname | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub nickname: Option<String>, | ||
/// Avatar attachment | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub avatar: Option<File>, | ||
|
||
/// Member's roles | ||
#[cfg_attr( | ||
feature = "serde", | ||
serde(skip_serializing_if = "Vec::is_empty", default) | ||
)] | ||
pub roles: Vec<String>, | ||
/// Timestamp this member is timed out until | ||
#[cfg_attr(feature = "serde", serde(skip_serializing_if = "Option::is_none"))] | ||
pub timeout: Option<Timestamp>, | ||
} | ||
|
||
/// Composite primary key consisting of server and user id | ||
#[derive(Hash, Default)] | ||
pub struct MemberCompositeKey { | ||
/// Server Id | ||
pub server: String, | ||
/// User Id | ||
pub user: String, | ||
} | ||
); |