2024-12-28 21:35:45 +03:00
|
|
|
use base64::Engine;
|
|
|
|
use axum::{response::{Response, IntoResponse}, Json, http::StatusCode};
|
|
|
|
use serde::Serialize;
|
|
|
|
|
|
|
|
pub mod join;
|
|
|
|
pub mod has_joined;
|
|
|
|
pub mod profile;
|
|
|
|
pub mod textures;
|
|
|
|
pub use join::join;
|
|
|
|
pub use has_joined::has_joined;
|
|
|
|
pub use profile::profile;
|
|
|
|
pub use textures::serve_texture;
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct HasJoinedResponse {
|
|
|
|
id: String,
|
|
|
|
name: String,
|
|
|
|
properties: Vec<HasJoinedProperty>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize)]
|
|
|
|
pub struct HasJoinedProperty {
|
|
|
|
name: String,
|
|
|
|
value: String,
|
|
|
|
}
|
|
|
|
|
2025-01-19 22:08:10 +03:00
|
|
|
fn create_profile_response(uuid: String, username: String, skin_date: String, cape_date: String) -> Response {
|
2024-12-28 21:35:45 +03:00
|
|
|
let textures = serde_json::json!({
|
|
|
|
"timestamp": chrono::Utc::now().timestamp(),
|
|
|
|
"profileId": uuid,
|
|
|
|
"profileName": username,
|
|
|
|
"textures": {
|
|
|
|
"SKIN": {
|
2025-01-19 22:08:10 +03:00
|
|
|
"url": format!("https://root-kit.ru:3002/textures/skin/skin_{}_{}.png", uuid, skin_date),
|
2024-12-28 21:35:45 +03:00
|
|
|
"metadata": {
|
|
|
|
"model": "slim"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"CAPE": {
|
2025-01-19 22:08:10 +03:00
|
|
|
"url": format!("https://root-kit.ru:3002/textures/cape/cape_{}_{}.png", uuid, cape_date),
|
2024-12-28 21:35:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
let textures_base64 = base64::engine::general_purpose::STANDARD.encode(textures.to_string());
|
|
|
|
|
|
|
|
let response = HasJoinedResponse {
|
|
|
|
id: uuid,
|
|
|
|
name: username.clone(),
|
|
|
|
properties: vec![HasJoinedProperty {
|
|
|
|
name: "textures".to_string(),
|
|
|
|
value: textures_base64,
|
|
|
|
}],
|
|
|
|
};
|
|
|
|
|
|
|
|
(StatusCode::OK, Json(response)).into_response()
|
|
|
|
}
|