mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 04:51:13 +03:00
func user_info fixed + "temporary" removed
This commit is contained in:
parent
f402d3d441
commit
3ff68fc4a6
3 changed files with 9 additions and 10 deletions
|
|
@ -2,11 +2,10 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use anyhow_http::{http_error_ret, response::Result};
|
use anyhow_http::{http_error_ret, response::Result};
|
||||||
use axum::{
|
use axum::{
|
||||||
body::Bytes,
|
body::Bytes, extract::{Path, State}, response::{IntoResponse, Response}
|
||||||
extract::{Path, State},
|
|
||||||
Json,
|
|
||||||
};
|
};
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
|
use reqwest::StatusCode;
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use serde_json::{json, Value};
|
use serde_json::{json, Value};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
|
|
@ -25,7 +24,7 @@ use super::types::S2CMessage;
|
||||||
pub async fn user_info(
|
pub async fn user_info(
|
||||||
Path(uuid): Path<Uuid>,
|
Path(uuid): Path<Uuid>,
|
||||||
State(state): State<AppState>,
|
State(state): State<AppState>,
|
||||||
) -> Json<Value> {
|
) -> Response {
|
||||||
tracing::info!("Receiving profile information for {}", uuid);
|
tracing::info!("Receiving profile information for {}", uuid);
|
||||||
|
|
||||||
let formatted_uuid = format_uuid(&uuid);
|
let formatted_uuid = format_uuid(&uuid);
|
||||||
|
|
@ -34,7 +33,7 @@ pub async fn user_info(
|
||||||
|
|
||||||
let auth_system = match state.user_manager.get_by_uuid(&uuid) {
|
let auth_system = match state.user_manager.get_by_uuid(&uuid) {
|
||||||
Some(d) => d.auth_system.to_string(),
|
Some(d) => d.auth_system.to_string(),
|
||||||
None => return Json(json!("err")),
|
None => return (StatusCode::NO_CONTENT, "not sculptor user".to_string()).into_response(), //(StatusCode::NOT_FOUND, "not found".to_string()).into_response(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut user_info_response = json!({
|
let mut user_info_response = json!({
|
||||||
|
|
@ -83,7 +82,7 @@ pub async fn user_info(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Json(user_info_response)
|
(StatusCode::OK, user_info_response.to_string()).into_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn download_avatar(Path(uuid): Path<Uuid>) -> Result<Vec<u8>> {
|
pub async fn download_avatar(Path(uuid): Path<Uuid>) -> Result<Vec<u8>> {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{sync::Arc, thread};
|
use std::sync::Arc;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
extract::{
|
extract::{
|
||||||
|
|
@ -173,9 +173,9 @@ async fn handle_socket(mut socket: WebSocket, state: AppState) {
|
||||||
}
|
}
|
||||||
// Closing connection
|
// Closing connection
|
||||||
if let Some(u) = owner {
|
if let Some(u) = owner {
|
||||||
// state.session.remove(&u.uuid); // FIXME: Temporary solution
|
state.session.remove(&u.uuid); // FIXME: Temporary solution
|
||||||
// state.broadcasts.remove(&u.uuid); // NOTE: Create broadcasts manager ??
|
// state.broadcasts.remove(&u.uuid); // NOTE: Create broadcasts manager ??
|
||||||
// state.user_manager.remove(&u.uuid);
|
state.user_manager.remove(&u.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,7 @@ async fn main() -> Result<()> {
|
||||||
.route("/motd", get(api_info::motd))
|
.route("/motd", get(api_info::motd))
|
||||||
.route("/equip", post(api_profile::equip_avatar))
|
.route("/equip", post(api_profile::equip_avatar))
|
||||||
.route("/:uuid", get(api_profile::user_info))
|
.route("/:uuid", get(api_profile::user_info))
|
||||||
.route("/:uuid/avatar", get(api_profile::download_avatar).layer(DefaultBodyLimit::disable()))
|
.route("/:uuid/avatar", get(api_profile::download_avatar))
|
||||||
.route("/avatar", put(api_profile::upload_avatar).layer(DefaultBodyLimit::disable()))
|
.route("/avatar", put(api_profile::upload_avatar).layer(DefaultBodyLimit::disable()))
|
||||||
.route("/avatar", delete(api_profile::delete_avatar));
|
.route("/avatar", delete(api_profile::delete_avatar));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue