fix: small delay during registration, send profile

This commit is contained in:
əlemi 2023-05-09 01:45:41 +02:00
parent 751921e25a
commit 5c5e878cea
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -1,3 +1,5 @@
use std::time::Duration;
use axum::{extract::State, Json}; use axum::{extract::State, Json};
use reqwest::StatusCode; use reqwest::StatusCode;
use sea_orm::{EntityTrait, QueryFilter, ColumnTrait, Set, ActiveValue::NotSet}; use sea_orm::{EntityTrait, QueryFilter, ColumnTrait, Set, ActiveValue::NotSet};
@ -12,7 +14,7 @@ pub async fn register_unmigrated(State(state): State<AppState>, Json(payload): J
let form = proto::RefreshRequest { let form = proto::RefreshRequest {
accessToken: payload.token.accessToken, accessToken: payload.token.accessToken,
clientToken: payload.token.clientToken, clientToken: payload.token.clientToken,
selectedProfile: None, selectedProfile: Some(payload.token.selectedProfile.clone()),
requestUser: Some(true), requestUser: Some(true),
}; };
@ -48,6 +50,8 @@ pub async fn register_unmigrated(State(state): State<AppState>, Json(payload): J
.map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, Json(proto::Error::simple("db error"))))? .map_err(|_| (StatusCode::INTERNAL_SERVER_ERROR, Json(proto::Error::simple("db error"))))?
.ok_or((StatusCode::INTERNAL_SERVER_ERROR, Json(proto::Error::simple("failed creating user"))))?; .ok_or((StatusCode::INTERNAL_SERVER_ERROR, Json(proto::Error::simple("failed creating user"))))?;
tokio::time::sleep(Duration::from_millis(500)).await; // avoid errors fetching skin due to timings
let url = format!("https://sessionserver.mojang.com/session/minecraft/profile/{}?unsigned=false", uuid.simple()); let url = format!("https://sessionserver.mojang.com/session/minecraft/profile/{}?unsigned=false", uuid.simple());
let res = reqwest::Client::new().get(url.clone()) //TODO: needs trimmed uuid, is it trimmed by default? let res = reqwest::Client::new().get(url.clone()) //TODO: needs trimmed uuid, is it trimmed by default?
.json(&()).send() .json(&()).send()