Compare commits
10 Commits
af03fe896f
...
ac93f4ba37
Author | SHA1 | Date | |
---|---|---|---|
|
ac93f4ba37 | ||
|
35639161bf | ||
|
2fc2540321 | ||
|
9ac42f82e6 | ||
|
cd828ed1b0 | ||
|
445871ff4c | ||
|
4029c57134 | ||
|
a83e4b5954 | ||
|
6f7237098a | ||
|
7641284360 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -60,7 +60,7 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
||||
[[package]]
|
||||
name = "dev-dtos"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/franklinblanco/user-dtos.git#3b3ffde695753edb4e7ffdf722299b372f2c0bd0"
|
||||
source = "git+https://github.com/franklinblanco/user-svc-dtos-rust.git#80abf74269baf13b9fc1d186516564b0d4521270"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"serde",
|
||||
|
@ -16,4 +16,4 @@ chrono = { version = "0.4", features = [ "serde" ] }
|
||||
rust_decimal = "1.26"
|
||||
|
||||
err = { git = "https://github.com/franklinblanco/err.git" }
|
||||
dev-dtos = { git = "https://github.com/franklinblanco/user-dtos.git" }
|
||||
dev-dtos = { git = "https://github.com/franklinblanco/user-svc-dtos-rust.git" }
|
||||
|
@ -8,8 +8,10 @@ pub enum LeaguePlayerStatus {
|
||||
/// The player requested to join but got denied by the league owner
|
||||
Denied,
|
||||
/// The player joined either by getting accepted or by joining an open league
|
||||
/// Active group (Can only have one at a time)
|
||||
Joined,
|
||||
/// The player is requesting to join a league
|
||||
/// Active group (Can only have one at a time)
|
||||
#[default]
|
||||
Requested,
|
||||
/// The player was already in a league and was kicked out.
|
||||
@ -47,7 +49,35 @@ impl FromStr for LeaguePlayerStatus {
|
||||
"Left" => Ok(Self::Requested),
|
||||
"Invited" => Ok(Self::Invited),
|
||||
"Canceled" => Ok(Self::Canceled),
|
||||
_ => Err(Error::Unspecified) //TODO: Create ParseStr error in actix_web_utils
|
||||
_ => Err(Error::Unspecified),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum StatusType {
|
||||
/// Inside a league
|
||||
Active,
|
||||
/// Either outside of a league, or attempting to join
|
||||
Inactive,
|
||||
}
|
||||
|
||||
impl LeaguePlayerStatus {
|
||||
pub fn get_status_type(&self) -> StatusType {
|
||||
match self {
|
||||
LeaguePlayerStatus::Denied => StatusType::Inactive,
|
||||
LeaguePlayerStatus::Joined => StatusType::Active,
|
||||
LeaguePlayerStatus::Requested => StatusType::Active,
|
||||
LeaguePlayerStatus::Kicked => StatusType::Inactive,
|
||||
LeaguePlayerStatus::Left => StatusType::Inactive,
|
||||
LeaguePlayerStatus::Invited => StatusType::Inactive,
|
||||
LeaguePlayerStatus::Canceled => StatusType::Inactive,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum ApprovalStatus {
|
||||
Approved,
|
||||
Denied,
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
pub mod player;
|
||||
pub mod league;
|
||||
pub mod league_player;
|
||||
pub mod trust;
|
||||
pub mod trust;
|
||||
pub mod player_metadata;
|
24
src/dto/player_metadata.rs
Normal file
24
src/dto/player_metadata.rs
Normal file
@ -0,0 +1,24 @@
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
use crate::domain::player::Player;
|
||||
|
||||
|
||||
/// Mainly used for the Chat, so that a user can request and store many players info
|
||||
/// Should be as small as possible to reduce strain on servers and client storage.
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||
pub struct PlayerMetadata {
|
||||
pub id: u32,
|
||||
pub name: String,
|
||||
pub profile_picture_url: Option<String>,
|
||||
}
|
||||
|
||||
impl From<Player> for PlayerMetadata {
|
||||
fn from(value: Player) -> Self {
|
||||
PlayerMetadata { id: value.id, name: value.name, profile_picture_url: value.profile_picture_url }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||
pub struct PlayerIds {
|
||||
pub ids: Vec<u32>
|
||||
}
|
Loading…
Reference in New Issue
Block a user