Compare commits

...

10 Commits

Author SHA1 Message Date
Franklin ac93f4ba37 Removed sqlx dep and fromrow from player 2023-01-24 19:15:17 -04:00
Franklin 35639161bf Fromrow added for player 2023-01-24 19:12:30 -04:00
Franklin 2fc2540321 Playerids added 2023-01-24 18:57:07 -04:00
Franklin 9ac42f82e6 Added playermetadata struct 2023-01-24 18:50:49 -04:00
Franklin cd828ed1b0 Changed repo 2022-10-23 00:07:37 -04:00
Franklin 445871ff4c Added approval status 2022-10-22 23:54:20 -04:00
Franklin 4029c57134 Implemented default traits 2022-10-16 21:18:00 -04:00
Franklin a83e4b5954 changed requested status to active 2022-10-16 21:09:51 -04:00
Franklin 6f7237098a Added status type 2022-10-16 19:26:53 -04:00
Franklin 7641284360 Added comments to status enums 2022-10-16 18:56:41 -04:00
5 changed files with 59 additions and 4 deletions

2
Cargo.lock generated
View File

@ -60,7 +60,7 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
[[package]] [[package]]
name = "dev-dtos" name = "dev-dtos"
version = "0.1.0" 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 = [ dependencies = [
"chrono", "chrono",
"serde", "serde",

View File

@ -16,4 +16,4 @@ chrono = { version = "0.4", features = [ "serde" ] }
rust_decimal = "1.26" rust_decimal = "1.26"
err = { git = "https://github.com/franklinblanco/err.git" } 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" }

View File

@ -8,8 +8,10 @@ pub enum LeaguePlayerStatus {
/// The player requested to join but got denied by the league owner /// The player requested to join but got denied by the league owner
Denied, Denied,
/// The player joined either by getting accepted or by joining an open league /// The player joined either by getting accepted or by joining an open league
/// Active group (Can only have one at a time)
Joined, Joined,
/// The player is requesting to join a league /// The player is requesting to join a league
/// Active group (Can only have one at a time)
#[default] #[default]
Requested, Requested,
/// The player was already in a league and was kicked out. /// The player was already in a league and was kicked out.
@ -47,7 +49,35 @@ impl FromStr for LeaguePlayerStatus {
"Left" => Ok(Self::Requested), "Left" => Ok(Self::Requested),
"Invited" => Ok(Self::Invited), "Invited" => Ok(Self::Invited),
"Canceled" => Ok(Self::Canceled), "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,
} }

View File

@ -1,4 +1,5 @@
pub mod player; pub mod player;
pub mod league; pub mod league;
pub mod league_player; pub mod league_player;
pub mod trust; pub mod trust;
pub mod player_metadata;

View 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>
}