Launcher: BlueMap view with player side panel, map actions, guild invitations

This commit is contained in:
Claude committed 2026-09-30 20:15:32 +00:00
1 parent 878827625a
commit e160ad8da3
10 files changed
+342 -7

No files matched your search

+48
View File
@@ -1190,3 +1190,51 @@ pub async fn like_user_post(state: State<'_, AppState>, post_id: i64) -> Res<boo
let body: serde_json::Value = resp.json().await.map_err(err)?;
Ok(body["liked"].as_bool().unwrap_or(false))
}
// ---------------------------------------------------------------------------
// Map actions and guild invitations
// ---------------------------------------------------------------------------
async fn ok_or_panel_error(resp: reqwest::Response, fallback: &str) -> Res<serde_json::Value> {
if resp.status().is_success() {
return Ok(resp.json().await.unwrap_or(serde_json::Value::Null));
}
let body: serde_json::Value = resp.json().await.unwrap_or_default();
Err(body["error"].as_str().or(body["message"].as_str()).unwrap_or(fallback).to_string())
}
/// From the map: ask a player to teleport to, or send them a message in game.
#[tauri::command]
pub async fn map_action(state: State<'_, AppState>, server_id: i64, action: String, target_uuid: String, text: Option<String>) -> Res<()> {
let req = account_api(&state, reqwest::Method::POST, &format!("/servers/{server_id}/map/actions")).await?;
let resp = req
.json(&serde_json::json!({ "action": action, "target_uuid": target_uuid, "text": text.unwrap_or_default() }))
.send()
.await
.map_err(err)?;
ok_or_panel_error(resp, "unable to do that right now").await.map(|_| ())
}
/// Invite a player to a guild you lead or officiate.
#[tauri::command]
pub async fn guild_send_invite(state: State<'_, AppState>, guild_id: String, target_uuid: String) -> Res<serde_json::Value> {
let req = account_api(&state, reqwest::Method::POST, &format!("/guilds/{guild_id}/invites")).await?;
let resp = req.json(&serde_json::json!({ "uuid": target_uuid })).send().await.map_err(err)?;
ok_or_panel_error(resp, "unable to send the invitation").await
}
#[tauri::command]
pub async fn my_guild_invites(state: State<'_, AppState>) -> Res<serde_json::Value> {
let req = account_api(&state, reqwest::Method::GET, "/guilds/invites").await?;
let resp = req.send().await.map_err(err)?;
ok_or_panel_error(resp, "unable to load invitations").await
}
#[tauri::command]
pub async fn respond_guild_invite(state: State<'_, AppState>, invite_id: i64, accept: bool) -> Res<serde_json::Value> {
let path = format!("/guilds/invites/{invite_id}/{}", if accept { "accept" } else { "decline" });
let req = account_api(&state, reqwest::Method::POST, &path).await?;
let resp = req.send().await.map_err(err)?;
ok_or_panel_error(resp, "unable to answer the invitation").await
}