Initial Commit

This commit is contained in:
BloxerHD 2026-02-12 11:56:29 +00:00
commit c09b00ff35
30 changed files with 1930 additions and 0 deletions

95
src/models/file_wup.rs Normal file
View file

@ -0,0 +1,95 @@
use chrono::NaiveDateTime;
use serde::{Serialize, Deserialize};
use sqlx::{FromRow, Decode, Encode, types::Json};
const VALID_COUNTRIES: &[&str] = &[
"GB", "US", "IT", "NL", "DE", "CA", "FR", "HU", "CR",
"AU", "BR", "RO", "CL", "MX", "RU", "ES", "JP", "CZ",
"PT", "MT", "AR", "SE", "PL", "IE", "BE", "HT", "NO",
"FI", "GR", "BO", "AT", "VE", "PA", "PE", "GF", "SA",
"CO", "LT", "NA", "CH", "CY", "RS", "KY", "GP", "DK",
"KR", "LU", "SV", "VA", "GT", "SK", "HR", "ZA", "DO",
"UY", "LV", "HN", "JM", "TR", "IN", "ER", "AW", "NZ",
"EC", "TW", "EE", "CN", "SI", "AI", "BG", "NI", "IS",
"MQ", "BZ", "BA", "MY", "AZ", "ZW", "AL", "IM", "VG",
"VI", "BM", "GY", "SR", "MS", "TC", "BB", "TT",
];
const VALID_LANGUAGES: &[&str] = &[
"en", "it", "de", "fr", "es", "us", "pt", "ru", "ja", "nl", "ko", "zh", "tw",
];
const VALID_FILE_TYPES: &[&str] = &[
"Message",
"AppData",
];
const VALID_FILE_NOTIFY_CONDITIONS: &[&str] = &[
"app",
"account",
];
pub fn is_valid_countries(countries: &Vec<String>) -> bool {
for country in countries {
match VALID_COUNTRIES.contains(&country.as_str()) {
true => (),
false => return false,
}
}
true
}
pub fn is_valid_languages(languages: &Vec<String>) -> bool {
for lang in languages {
match VALID_LANGUAGES.contains(&lang.as_str()) {
true => (),
false => return false,
}
};
true
}
pub fn is_valid_file_type(file_type: &str) -> bool {
VALID_FILE_TYPES.contains(&file_type)
}
pub fn is_valid_file_notify_conditions(conditions: &Vec<String>) -> bool {
for condition in conditions {
match VALID_FILE_NOTIFY_CONDITIONS.contains(&condition.as_str()) {
true => (),
false => return false,
}
};
true
}
#[derive(Serialize, Deserialize, Decode, Encode, Clone)]
pub struct FileWUPAttributes {
pub attribute1: String,
pub attribute2: String,
pub attribute3: String,
pub description: String,
}
#[derive(FromRow, Clone)]
pub struct FileWUP {
pub deleted: bool,
pub file_key: String,
pub data_id: Option<i64>,
pub task_id: String,
pub boss_app_id: String,
pub supported_countries: Vec<String>,
pub supported_languages: Vec<String>,
pub attributes: Json<FileWUPAttributes>,
pub creator_user: String,
pub name: String,
pub r#type: String,
pub hash: String,
pub size: i64,
pub notify_on_new: Vec<String>,
pub notify_led: bool,
pub condition_played: i64,
pub auto_delete: bool,
pub created: NaiveDateTime,
pub updated: NaiveDateTime,
}

2
src/models/mod.rs Normal file
View file

@ -0,0 +1,2 @@
pub mod task;
pub mod file_wup;

27
src/models/task.rs Normal file
View file

@ -0,0 +1,27 @@
use chrono::NaiveDateTime;
use serde::{Serialize, Deserialize};
use sqlx::Type;
const VALID_TASK_STATUSES: &[&str] = &[
"open",
"close",
];
pub fn is_valid_task_status(status: &str) -> bool {
VALID_TASK_STATUSES.contains(&status)
}
#[derive(Clone)]
pub struct Task {
pub deleted: bool,
pub id: String,
pub in_game_id: String,
pub boss_app_id: String,
pub creator_user: String,
pub status: String,
pub interval: i32,
pub title_id: String,
pub description: String,
pub created: NaiveDateTime,
pub updated: NaiveDateTime,
}