Adapt API v2 and v3 to new DB Schema
This commit is contained in:
parent
35807d66ab
commit
134581f8ad
3 changed files with 23 additions and 6 deletions
|
@ -42,10 +42,15 @@ pub struct Empire {
|
|||
pub group_id: i32,
|
||||
pub game_id: i32,
|
||||
pub name: String,
|
||||
pub discord_user: Option<String>,
|
||||
pub gestalt: bool,
|
||||
pub portrait_id: i32,
|
||||
pub portrait_group_id: i32,
|
||||
pub backstory: String,
|
||||
pub goals: String,
|
||||
pub interactions: String,
|
||||
pub available: bool,
|
||||
pub approval_status: Option<bool>,
|
||||
pub users_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema, Debug, FromRow)]
|
||||
|
@ -55,3 +60,15 @@ pub struct EmpireEthic {
|
|||
pub ethics_id: i32,
|
||||
pub fanatic: bool,
|
||||
}
|
||||
|
||||
#[derive(Serialize, ToSchema, Debug, FromRow)]
|
||||
pub struct User {
|
||||
pub id: i32,
|
||||
pub token: String,
|
||||
pub discord_id: Option<String>,
|
||||
pub picture_url: Option<String>,
|
||||
pub game_permissions: bool,
|
||||
pub empire_permissions: bool,
|
||||
pub data_permissions: bool,
|
||||
pub user_permissions: bool,
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ pub(crate) async fn empires(
|
|||
|
||||
if let Some(auth_token) = params.token.clone() {
|
||||
if auth_token == data.auth_tokens.admin || auth_token == data.auth_tokens.moderator {
|
||||
new_data.discord_user = entry.discord_user.clone();
|
||||
new_data.discord_user = Some("deprecated".to_string());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ pub(crate) async fn get_game_data(
|
|||
"[REDACTED]".to_string()
|
||||
},
|
||||
discord_user: if user_auth.moderator || user_auth.admin {
|
||||
empire.discord_user.clone()
|
||||
Some("deprecated".to_string())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
@ -807,7 +807,7 @@ pub(crate) async fn get_empire(
|
|||
group: db_empire.group_id,
|
||||
game: db_empire.game_id,
|
||||
name: db_empire.name,
|
||||
discord_user: db_empire.discord_user,
|
||||
discord_user: Some("deprecated".to_string()),
|
||||
machine: db_empire.portrait_group_id.to_string() == dotenvy::var("MACHINE_GROUP_ID").unwrap_or("12".to_string()),
|
||||
gestalt: db_empire.gestalt,
|
||||
portrait_id: db_empire.portrait_id,
|
||||
|
@ -941,7 +941,7 @@ pub(crate) async fn create_empire(
|
|||
group: db_empire.group_id,
|
||||
game: db_empire.game_id,
|
||||
name: db_empire.name,
|
||||
discord_user: db_empire.discord_user,
|
||||
discord_user: Some("deprecated".to_string()),
|
||||
machine: db_empire.portrait_group_id.to_string() == dotenvy::var("MACHINE_GROUP_ID").unwrap_or("12".to_string()),
|
||||
gestalt: db_empire.gestalt,
|
||||
portrait_id: db_empire.portrait_id,
|
||||
|
@ -1174,7 +1174,7 @@ pub(crate) async fn edit_empire(
|
|||
group: db_empire.group_id,
|
||||
game: db_empire.game_id,
|
||||
name: db_empire.name,
|
||||
discord_user: db_empire.discord_user,
|
||||
discord_user: Some("deprecated".to_string()),
|
||||
machine: db_empire.portrait_group_id.to_string() == dotenvy::var("MACHINE_GROUP_ID").unwrap_or("12".to_string()),
|
||||
gestalt: db_empire.gestalt,
|
||||
portrait_id: db_empire.portrait_id,
|
||||
|
|
Reference in a new issue