feat(backend): remove server play analytics fallback (#5884)

Remove server play analytics fallback
This commit is contained in:
Arthur
2026-05-03 14:50:23 +02:00
committed by GitHub
parent 5b59e39a8a
commit f857d19aee

View File

@@ -252,9 +252,8 @@ struct MinecraftProfile {
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct MinecraftJavaServerPlayInput { pub struct MinecraftJavaServerPlayInput {
project_id: ProjectId, project_id: ProjectId,
username: Option<String>, username: String,
server_id: Option<String>, server_id: String,
minecraft_uuid: Option<Uuid>,
} }
pub const MINECRAFT_SERVER_PLAYS: &str = "minecraft_server_plays"; pub const MINECRAFT_SERVER_PLAYS: &str = "minecraft_server_plays";
@@ -292,44 +291,36 @@ async fn minecraft_server_play_ingest(
))); )));
} }
let minecraft_uuid = if let (Some(username), Some(server_id)) = let has_joined = http
(&play_input.username, &play_input.server_id) .get("https://sessionserver.mojang.com/session/minecraft/hasJoined")
.query(&[
("username", play_input.username.as_str()),
("serverId", play_input.server_id.as_str()),
])
.send()
.await
.wrap_internal_err("failed to contact Mojang session server")?;
if has_joined.status() == reqwest::StatusCode::NO_CONTENT
|| !has_joined.status().is_success()
{ {
let has_joined = http return Err(ApiError::Request(eyre!(
.get("https://sessionserver.mojang.com/session/minecraft/hasJoined") "Minecraft session verification failed"
.query(&[ )));
("username", username.as_str()), }
("serverId", server_id.as_str()),
])
.send()
.await
.wrap_internal_err("failed to contact Mojang session server")?;
if has_joined.status() == reqwest::StatusCode::NO_CONTENT let profile = has_joined
|| !has_joined.status().is_success() .json::<MinecraftProfile>()
{ .await
return Err(ApiError::Request(eyre!( .wrap_internal_err("invalid Mojang session response")?;
"Minecraft session verification failed"
)));
}
let profile = has_joined if profile.name != play_input.username {
.json::<MinecraftProfile>() return Err(ApiError::Request(eyre!(
.await "returned Mojang profile name does not match username"
.wrap_internal_err("invalid Mojang session response")?; )));
}
if profile.name != *username { let minecraft_uuid = profile.id;
return Err(ApiError::Request(eyre!(
"returned Mojang profile name does not match username"
)));
}
profile.id
} else {
play_input
.minecraft_uuid
.wrap_request_err("missing `minecraft_uuid`")?
};
let conn_info = req.connection_info().peer_addr().map(|x| x.to_string()); let conn_info = req.connection_info().peer_addr().map(|x| x.to_string());
let headers = req let headers = req